Exporting a space fails with error: No row with the given identifier exists

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.

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

Summary

Trying to export a space fails and the UI shows: Couldn't backup database data.

Diagnosis

Reviewing the logs we see:

ERROR [Long running task: Export Space] [confluence.importexport.impl.AbstractXmlExporter] backupEntities Couldn't backup database data.
 -- url: /spaces/doexportspace.action | referer: http://localhost/spaces/exportspacexml.action?key=spacekey | traceId: 01b066206465i6a8 | userName: admin | action: doexportspace
net.sf.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.atlassian.confluence.pages.Page#12345678]
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:111)

As we can see, content ID 12345678 could not be found during the export. This indicates that other contents are still referencing this ID although it no longer exists. To identify those broken references, run the following query:

select * from content 
where contenttype = 'page' 
and content_status = 'current' 
and prevver is null 
and parentid not in 
(select contentid from content)
order by spaceid;

This query searches for IDs that no longer exist as CONTENTIDs in the CONTENT table, but are referenced through the PARENTID column by other rows. If any result is returned, proceed with the solution below.

Cause

This situation should not happen under normal circumstances since this relation is protected by a foreign key:

    "fkoxtt893weujkyh0iicoxsm37v" FOREIGN KEY (parentid) REFERENCES content(contentid)


However, if FKs were disabled in the past for any database intervention, those inconsistencies could have been introduced manually.

Solution

(warning) The steps below need to be executed individually for each missing PARENTID returned by the diagnostics query. Test it first on a staging instance.

1- Create a new page under the home of the space where the PARENTID is missing (check the SPACEID column from the diagnostics query)

2- Set the name of the page exactly as follows, replace the ID accordingly:

new parent page for children of <MISSING PARENTID>

3- Stop Confluence

4- Take a database backup

5- Run the following query to change the parent of the problematic pages, replace the IDs accordingly:

update content 
set parentid = (select contentid from content 
where lowertitle = 'new parent page for children of <MISSING PARENTID>' and 
content_status = 'current' and 
prevver is null and 
spaceid = <SPACEID>) 
where parentid = <MISSING PARENTID>;

(warning) Check the number of updates, it should be the same as the number of pages associated with this ID before running the query.

6- Restart Confluence

7- Repeat all steps for other PARENTIDs that are missing

8- Run the diagnostics query again after fixing all inconsistencies, you should not see any results now

9- Rebuild the ancestors table as follows:

10- Check if those pages can now be accessed under the page created in step 1


Last modified on Nov 9, 2020

Was this helpful?

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