Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-52755

Unable to delete space after import from Atlassian Cloud hosted export/import

XMLWordPrintable

      Summary

      When trying to delete a space which was imported from a Cloud version then the import completes and we see a foreign key violation on the table fk_notifications_content in the logs

      Environment

      Cloud version
      Confluence 6.2.0

      Steps to Reproduce

      1. Export a space from cloud version
      2. Import it to Confluence 6.2.0
      3. Delete the imported space

      Expected Results

      The space should be deleted

      Actual Results

      The below exception is thrown in the atlassian-confluence.log file and space does not get deleted the progress is stuck at some point:

      2017-05-29 23:59:07,129 ERROR [Long running task: Space removal long running task] [engine.jdbc.spi.SqlExceptionHelper] logExceptions ERROR: update or delete on table "content" violates foreign key constraint "fk_notifications_content" on table "notifications"
        Detail: Key (contentid)=(1966804) is still referenced from table "notifications".
       -- space: 1998852 | url: /spaces/doremovespace.action | traceId: 608cac2fcc885b69 | userName: admin | referer: https://confluence.wiki.com/spaces/removespace.action?key=IT1 | action: doremovespace
      2017-05-29 23:59:07,131 ERROR [Long running task: Space removal long running task] [atlassian.confluence.event.ConfluenceEventDispatcher] run There was an exception thrown trying to dispatch event [com.atlassian.confluence.event.events.space.SpaceWillRemoveEvent[source=com.atlassian.confluence.spaces.DefaultSpaceManager@5aa6c096]] from the invoker [com.atlassian.confluence.event.ConfluenceListenerHandlersConfiguration$TimingListenerHandler$1$1@3fd3e159]
       -- space: 1998852 | url: /spaces/doremovespace.action | traceId: 608cac2fcc885b69 | userName: admin | referer: https://confluence.wiki.com/spaces/removespace.action?key=IT1 | action: doremovespace
      java.lang.RuntimeException: could not execute statement; SQL [n/a]; constraint [fk_notifications_content]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
      	at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:41)
      	at com.atlassian.confluence.event.ConfluenceListenerHandlersConfiguration$TimingListenerHandler$1$1.invoke(ConfluenceListenerHandlersConfiguration.java:69)
      	...
      
      

      Workaround

      Some users have resolved this issue by running the command below to delete invalid notifications tied to deleted pages in the space (Similar to solution from CONFSERVER-15964):

      DELETE FROM NOTIFICATIONS
      WHERE CONTENTID IN (
        SELECT CONTENTID FROM CONTENT
        WHERE (CONTENT_STATUS = 'deleted' AND SPACEID = <spaceid-here>)
           OR PREVVER IN (
             SELECT CONTENTID FROM CONTENT
             WHERE CONTENT_STATUS = 'deleted' AND SPACEID = <spaceid-here>));
      

      With direct database manipulation, be sure to test and validate these changes in a test environment and create all necessary backups prior to rolling any changes into a Production environment.

              lgrzyb lukasz
              b0e65afe5d42 Mark Benson
              Votes:
              31 Vote for this issue
              Watchers:
              58 Start watching this issue

                Created:
                Updated:
                Resolved: