Unable to delete a Confluence space due to "deleted object would be re-saved by cascade" error
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Problem
It is not possible to delete a Confluence space. The process hangs in the UI and the following appears in the atlassian-confluence.log
20XX-XX-XX XX:XX:XX,XXX 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@650ee893]] from the invoker [com.atlassian.confluence.event.ConfluenceListenerHandlersConfiguration$TimingListenerHandler$1$1@2da97d25]
-- space: 11111111 | url: /spaces/doremovespace.action | traceId: e0eb56d25a6493e4 | userName: admin | referer: http://localhost:8090/spaces/removespace.action?key=KEY | action: doremovespace
java.lang.RuntimeException: deleted object would be re-saved by cascade (remove deleted object from associations): [com.atlassian.confluence.pages.Page#1111111]. Listener: com.atlassian.confluence.core.listeners.BundledContentSpaceRemovalListener event: com.atlassian.confluence.event.events.space.SpaceWillRemoveEvent
at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:55)
20XX-XX-XX XX:XX:XX,XXX 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.content.attachment.AttachmentRemoveEvent[source=com.atlassian.confluence.pages.DefaultAttachmentManager@375ca47a]] from the invoker [SingleParameterMethodListenerInvoker{method=public void com.atlassian.confluence.plugins.conversion.listener.ConversionCacheListener.handleAttachmentDeletion(com.atlassian.confluence.event.events.content.attachment.AttachmentRemoveEvent), listener=com.atlassian.confluence.plugins.conversion.listener.ConversionCacheListener@41dcb743} (timed)]
-- space: 11111111 | url: /spaces/doremovespace.action | traceId: 472e2a91744750c8 | userName: admin | referer: http://localhost:8090/spaces/removespace.action?key=KEY | action: doremovespace
java.lang.RuntimeException: deleted object would be re-saved by cascade (remove deleted object from associations): [com.atlassian.confluence.pages.Attachment#11111111]. Listener: com.atlassian.confluence.plugins.conversion.listener.
Cause
Notice you may see several errors like the one above in the logs, mentioning different objects. To confirm you are facing this issue before running the workaround, check if you see one of the associated items below in one of the messages:
com.atlassian.confluence.pages.Page#<PAGEID>
com.atlassian.confluence.pages.Attachment#<ATTACHMENTID>
If you see one or more messages with this object mentioned, the associations causing the problem are pages in the trash.
Workaround
To avoid this problem, purge the space trash before deleting the space as follows:
- Go to the space you want to delete and choose Space tools > Content Tools from the bottom of the sidebar
- Choose Trash
- Choose Purge all to completely empty the trash
- Try to delete the space again
Note
It is not yet clear how to replicate this issue. Ideally, the space deletion tool would remove all objects associated with it automatically. However, there is a special condition not identified yet that can cause this situation.