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

Collaborative Editing cannot be enabled after importing a space from Confluence Cloud

XMLWordPrintable

      Summary

      After importing a space from Confluence Cloud, Collaborative Editing cannot be enabled in Confluence Server.

      Environment

      Confluence Cloud > Space Exported > Imported to Confluence Server

      How to Replicate

      1. Export a space from Confluence Cloud
      2. Import it to Confluence Server
      3. Attempt to either enable Collaborative Editing

      Expected Results

      Collaborative Editing is enabled

      Actual Results

      Collaborative Editing is not enabled and the following message is logged in atlassian-confluence.log

      2018-05-16 12:13:58,517 ERROR [Long running task: EnableTask] [plugins.synchrony.tasks.AbstractConfigLongRunningTask] runInternal An error occurred when running a Synchrony ConfigLongRunningTask
       -- url: /rest/synchrony-interop/enable | referer: https://confluence.example.com/admin/confluence-collaborative-editor-plugin/configure.action | traceId: 67bfdcb7c0b2beb7 | userName: admin
      org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [fk_notifications_content]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
      	at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:241)
      	at org.springframework.orm.hibernate5.HibernateTemplate.doExecute(HibernateTemplate.java:366)
      	at org.springframework.orm.hibernate5.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:326)
      	at com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao.findNamedQueryStringParams(HibernateObjectDao.java:444)
      	at com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao.findNamedQueryStringParam(HibernateObjectDao.java:320)
      	at com.atlassian.confluence.pages.persistence.dao.hibernate.AbstractHibernateAttachmentDao.getLatestVersionsOfAttachmentsWithAnyStatus(AbstractHibernateAttachmentDao.java:134)
      	at com.atlassian.confluence.pages.attachments.CachingAttachmentDao.getLatestVersionsOfAttachmentsWithAnyStatus(CachingAttachmentDao.java:138)
      	at com.atlassian.confluence.pages.DefaultAttachmentManager.getLatestVersionsOfAttachmentsWithAnyStatus(DefaultAttachmentManager.java:288)
      	at com.atlassian.confluence.pages.DelegatorAttachmentManager.getLatestVersionsOfAttachmentsWithAnyStatus(DelegatorAttachmentManager.java:75)
      	at com.atlassian.confluence.pages.CachingAttachmentManager.getLatestVersionsOfAttachmentsWithAnyStatus(CachingAttachmentManager.java:67)
      	...
      	at com.atlassian.confluence.pages.DefaultPageManager.lambda$removeStaleSharedDrafts$10(DefaultPageManager.java:763)
      	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
      	at com.atlassian.confluence.pages.DefaultPageManager.removeStaleSharedDrafts(DefaultPageManager.java:761)
      	...
      	at com.atlassian.confluence.plugins.synchrony.tasks.EnableTask.execute(EnableTask.java:53)
      	at com.atlassian.confluence.plugins.synchrony.tasks.AbstractConfigLongRunningTask.runInternal(AbstractConfigLongRunningTask.java:65)
      	at com.atlassian.confluence.util.longrunning.ConfluenceAbstractLongRunningTask.run(ConfluenceAbstractLongRunningTask.java:26)
      	at com.atlassian.confluence.util.longrunning.ManagedTask.run(ManagedTask.java:52)
      	at com.atlassian.confluence.impl.util.concurrent.ConfluenceExecutors$ThreadLocalContextTaskWrapper.lambda$wrap$1(ConfluenceExecutors.java:90)
      	at com.atlassian.confluence.vcache.VCacheRequestContextOperations.lambda$doInRequestContext$0(VCacheRequestContextOperations.java:50)
      	at com.atlassian.confluence.impl.vcache.VCacheRequestContextManager.doInRequestContextInternal(VCacheRequestContextManager.java:87)
      	at com.atlassian.confluence.impl.vcache.VCacheRequestContextManager.doInRequestContext(VCacheRequestContextManager.java:71)
      	at com.atlassian.confluence.vcache.VCacheRequestContextOperations.doInRequestContext(VCacheRequestContextOperations.java:49)
      	at com.atlassian.confluence.vcache.VCacheRequestContextOperations.lambda$withRequestContext$2(VCacheRequestContextOperations.java:66)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
      	at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)
      	at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
      	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
      	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
      	at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:207)
      	at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)
      	at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3246)
      	at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3483)
      	at org.hibernate.action.internal.EntityDeleteAction.execute(EntityDeleteAction.java:99)
      	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:582)
      	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:456)
      	at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)
      	at org.hibernate.event.internal.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:50)
      	at org.hibernate.internal.SessionImpl.autoFlushIfRequired(SessionImpl.java:1366)
      	at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1451)
      	at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1426)
      	at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1398)
      	at com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao.lambda$findNamedQueryStringParams$5(HibernateObjectDao.java:468)
      	at org.springframework.orm.hibernate5.HibernateTemplate.doExecute(HibernateTemplate.java:359)
      	... 85 more
      Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "content" violates foreign key constraint "fk_notifications_content" on table "notifications"
        Detail: Key (contentid)=(4423910) is still referenced from table "notifications".
      	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455)
      	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155)
      	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288)
      	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430)
      	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356)
      	at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:168)
      	at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:135)
      	at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:410)
      	at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:204)
      	... 99 more
      

      Investigation Done

      Similar to CONFSERVER-52755, the foreign key violations must be fixed before Collaborative Editing can be enabled:

      ERROR: update or delete on table "content" violates foreign key constraint "fk_notifications_content" on table "notifications"
      

      Workaround

      Specific approach

      If you have already encountered this error, you may also parse your logs for specific contentid's to remove. Run this against the directory containing the atlassian-confluence.log files, like this example:

      $ grep 'is still referenced from table \"notifications\"' atlassian-confluence.* | awk '{print $4}' | sort | uniq | awk -F"[()]" '{print $4}'
      21659807
      21659827
      21659896
      4423910
      4423941
      4423953
      4423966
      4423967
      4423968
      4424797
      4424798
      4424936
      

      Taking the above contentid's (as all of them must be removed), form a delete query to remove the bad data:

      1. Backup your database
      2. Run this SQL to delete the invalid notifications:
        DELETE FROM notifications where contentid in (21659807,21659827,21659896,4423910,4423941,4423953,4423966,4423967,4423968,4424797,4424798,4424936);
        
      3. Attempt to then enable Collaborative Editing.
      4. If the issue is not resolved at that point, execute the next SQL statement to remove all invalid notifications, under Broad Approach below.

      Broad Approach

      Some users have resolved this issue by running the command below to delete invalid notifications tied to deleted pages in the (imported from cloud) space:
      You must backup up your database before performing the following task.

      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>));
      

              lgrzyb lukasz
              jwyllys Justin W.
              Votes:
              3 Vote for this issue
              Watchers:
              12 Start watching this issue

                Created:
                Updated:
                Resolved: