Unable to Delete Space in Confluence Data Center
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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
Symptoms
An error is thrown when deleting a space. Appearing in the logs is one of:
a constraint violation
a NullPointerException
a org.springframework.dao.DataIntegrityViolationException
Diagnosis
There is an invalid entry or foreign key relationship in the database. Inspect the stack trace you receive from the error. See below for the corresponding solution.
Causes and Resolutions
org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result
There are duplicate labels in the database. This issue is tracked in CONFSERVER-5254 - Duplicate labels can be created by Concurrency Requests.
org.springframework.dao.DataIntegrityViolationException: Hibernate operation: could not delete com.atlassian.confluence.pages.templates.PageTemplate
This issue is tracked in CONFSERVER-19490 - Removing Space with multiple Page Templates and multiple page templates versions will fail with Foreign Key Contraints. It was resolved in Confluence 3.3. Please see the bug report for the workaround if you are on 3.3 or before.
org.springframework.dao.DataIntegrityViolationException: Hibernate operation: could not delete com.atlassian.confluence.pages.Attachment
This issue is tracked in CONFSERVER-19611 - Unable to remove a space - gives a DataIntegrityViolationException. It was resolved in Confluence 4.1.2. Please see the bug report for the workaround if you are on 4.1.2 or before.
Further Help
If you are unable to access the space at all from the UI, you can run the deletion from the URL directly at http://<baseURL>/spaces/removespace.action?key=<insert space key>. If that fails to work, refer to the documentation on Manually Deleting a Space.
Quick Workarounds
Try to Purge the Space Trash first and then attempt to delete the Space again.
From the application logs or UI, if you encounter an issue with a particular page which is causing issue during the Space Delete operation, try and move/copy the page to a different space and then attempt to delete the Space in question.
If you find you're still having problems, you may need to get a bit more information about what specifically is causing problems.
If you can reproduce the problem on a test instance, use these steps there before trying this in production.
Shut down Confluence
Enable sql loggingwith parameters.
Restart Confluence and attempt to delete the space, recreating the error.
View the atlassian-confluence.log. You'll find the culprit space and the offending database row.
If you have any questions about which rows to delete, create a support ticket and attach the detailed logs.
Was this helpful?