When we try to delete a space which was imported from a Cloud version then the import does not complete and we see a foreign key violation on the table usercontent_relation in the logs
Steps to Reproduce
- Export a space from cloud version
- Import it to Confluence 5.10.x
- Delete the imported space
The space should be deleted
The below exception is thrown in the atlassian-confluence.log file and space does not get deleted the progress is stuck at some point:
2016-10-07 21:51:50,457 ERROR [Long running task: Space removal long running task] [atlassian.confluence.event.ConfluenceEventDispatcher] lambda$getRunnable$1 There was an exception thrown trying to dispatch event [com.atlassian.confluence.event.events.space.SpaceWillRemoveEvent[source=com.atlassian.confluence.spaces.DefaultSpaceManager@422da8a5]] from the invoker [com.atlassian.confluence.event.ConfluenceListenerHandlersConfiguration$TimingListenerHandler$1$1@43b5b300]
-- space: 98307 | url: /spaces/doremovespace.action | traceId: 187467d29377f21f | userName: admin | referer: http://localhost:8090/spaces/removespace.action?key=MIZ | action: doremovespace
java.lang.RuntimeException: Hibernate operation: could not delete: [com.atlassian.confluence.pages.Page#65601]; SQL ; ERROR: update or delete on table "content" violates foreign key constraint "fkecd19ced351d64c3" on table "usercontent_relation"
Detail: Key (contentid)=(65601) is still referenced from table "usercontent_relation".; nested exception is org.postgresql.util.PSQLException: ERROR: update or delete on table "content" violates foreign key constraint "fkecd19ced351d64c3" on table "usercontent_relation"
Detail: Key (contentid)=(65601) is still referenced from table "usercontent_relation".
Please take a Db backup and throughly test the below workaround before applying it to production instance
A workaround is to truncate the table
TRUNCATE table USERCONTENT_RELATION;