Delete space failed error when trying to delete a space within Confluence 5.6.x or older versions
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
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.
*Fisheye および Crucible は除く
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 well within your infrastructure prior to placing these changes in production.
Confluence 5.7.x or later: In case we need to remove a space from the database after a failed space delete, please, follow this KB instead.
環境
Confluence 5.6.x and older versions.
問題
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
原因
There are still some attachment references in the attachmentdata table relating to the space getting deleted. This causes the following constraint to fail:
ALTER TABLE attachmentdata
ADD CONSTRAINT fk9dc3e34d34a4917e FOREIGN KEY (attachmentid)
REFERENCES content (contentid) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION;
回避策
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');