Error when deleting a space in Confluence
Asked by Sigursteinn BJarni H?bertsson:

Hi all.  

I've seen a lot of posts regarding errors on deleting spaces in confluence, but none seems to match what I am experiencing.  

There was a space imported from another confluence instance to the one i'm working on.  

The import was not successful and the space needs to be deleted.  

The error when I try to delete the space is the following.

```
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@47d4468a]] from the invoker [SingleParameterMethodListenerInvoker{method=public void com.atlassian.confluence.content.CustomContentSpaceRemovalListener.spaceIsBeingRemoved(com.atlassian.confluence.event.events.space.SpaceWillRemoveEvent), listener=com.atlassian.confluence.content.CustomContentSpaceRemovalListener@7debed5a} (timed)]
-- space: 100728840 | url: /spaces/doremovespace.action | traceId: d200cbbc58da3b43 | userName: Username | referer: https://xxxx.xxx.xxx/spaces/removespace.action?key=SPACENAME | action: doremovespace
java.lang.RuntimeException: Listener: com.atlassian.confluence.content.CustomContentSpaceRemovalListener event: com.atlassian.confluence.event.events.space.SpaceWillRemoveEvent

Caused by: java.lang.NullPointerException
```

```
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.SpaceRemoveEvent[source=com.atlassian.confluence.spaces.DefaultSpaceManager@47d4468a]] from the invoker [SingleParameterMethodListenerInvoker{method=public void com.atlassian.confluence.extra.calendar3.contenttype.DefaultCalendarContentTypeManager.handleSpaceRemoved(com.atlassian.confluence.event.events.space.SpaceRemoveEvent), listener=com.atlassian.confluence.extra.calendar3.contenttype.DefaultCalendarContentTypeManager@1e618303} (timed)]
-- space: 100728840 | url: /spaces/doremovespace.action | traceId: d200cbbc58da3b43 | userName: Username | referer: https://xxxx.xxx.xxx/spaces/removespace.action?key=SPACENAME | action: doremovespace
java.lang.RuntimeException: deleted object would be re-saved by cascade (remove deleted object from associations): [com.atlassian.confluence.spaces.Space#100728840]. Listener: com.atlassian.confluence.extra.calendar3.contenttype.DefaultCalendarContentTypeManager event: com.atlassian.confluence.event.events.space.SpaceRemoveEvent

Caused by: javax.persistence.EntityNotFoundException: deleted object would be re-saved by cascade (remove deleted object from associations): [com.atlassian.confluence.spaces.Space#100728840]
```

I tried to remove all the pages for the space and then delete but with out any luck.  

There are now over 1500 pages in the space trash and I am getting this error when i'm trying to purge.

```


caused by: org.springframework.orm.hibernate5.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:283)
caused by: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:67)

```

I know the answer to this purge problem is referenced here   
<https://jira.atlassian.com/browse/CONFSERVER-57823>  

But the sql query depends on you knowing the title of content, which I do not.

If I put sapce id in this query I get 1510 results, and I cannot spend the next weeks manually deleting pages form the trash.

```

SELECT s.spacekey, 
c.contentid, 
c.title, 
c.contenttype, 
c.content_status 
FROM content c 
JOIN spaces s 
ON c.spaceid = s.spaceid 
WHERE c.contentid IN 
( 
SELECT pageid 
FROM content 
WHERE contenttype = 'CUSTOM' 
AND spaceid = my_spaceid?
AND content_status = 'deleted');
```

<br />

The conflunce version i 6.15.2


Answers:
author: Fabian Lim
body: Hi [@Sigursteinn BJarni H?bertsson](/t5/user/viewprofilepage/user-id/4149235)

I recommend you open a ticket with atlassian support if you are still experiencing this issue: <https://support.atlassian.com/contact/#/>

Ensure you provide all the logs.

Regards


Tags: confluence-server

database

delete

server

space