Delete space failed error when trying to delete a space within Confluence

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Server and Data Center Only - This article only applies to Atlassian products on the server and data center platforms.

Problem

The error "Delete space failed" is shown in the user interface when a user tries to delete a space within Confluence. The following appears in the atlassian-confluence.log

ERROR [Long running task: Space removal long running task] [atlassian.event.internal.AsynchronousAbleEventDispatcher] run There was an exception thrown trying to dispatch event 'com.atlassian.confluence.event.events.space.SpaceWillRemoveEvent[source=com.atlassian.confluence.spaces.DefaultSpaceManager@4836e98b]' from the invoker 'SingleParameterMethodListenerInvoker
...
action: doremovespace
java.lang.RuntimeException: Hibernate operation: could not delete: [com.atlassian.confluence.pages.Attachment#]; SQL []; ORA-02292: integrity constraint (WIKI.FK9DC3E34D34A4917E) violated - child record found
; nested exception is java.sql.SQLIntegrityConstraintViolationException: ORA-02292: integrity constraint (WIKI.FK9DC3E34D34A4917E) violated - child record found

Cause

There are still some attachment references in the attachmentdata table relating to the space getting deleted. This causes the following constraint to fail:

Constraint
ALTER TABLE attachmentdata
  ADD CONSTRAINT fk9dc3e34d34a4917e FOREIGN KEY (attachmentid)
      REFERENCES content (contentid) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION;

 

Workaround

The workaround is to delete these related entries in the attachmentdata table prior to running the delete function. Since you are planning to delete the space, deleting the related entries will make sure the constraint does not fail.

  • Note: Make sure to update the space key at the end of the query with the space key for the problematic space. 

    delete from attachmentdata where attachmentid in (select a.attachmentid from attachments a join content c on a.pageid=c.contentid join spaces s on c.spaceid=s.spaceid where s.spacekey='SPACEKEY');

    PLEASE READ: As with all recommendations made by Atlassian Support, please follow best practices for Change Management and *test and validate* these settings in a Test/Development and Staging environment prior to rolling any changes into a Production environment. This is to validate these changes and ensure that they will function will within your infrastructure prior to placing these changes in production.

Last modified on Apr 7, 2016

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.