Upgrade Fails Due to a Violation on CONTENT

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

Summary

Symptoms

Upgrade of Confluence fails.

The following appears in the atlassian-confluence.log:

1 2 3 4 5 6 7 8 9 10 2014-02-11 11:03:18,783 ERROR [main] [hibernate.tool.hbm2ddl.SchemaUpdate] execute Unsuccessful: alter table CONTENT add constraint FKxxxxxxxxxxx foreign key (PARENTID) references CONTENT (CONTENTID) 2014-02-11 11:03:18,834 ERROR [main] [hibernate.tool.hbm2ddl.SchemaUpdate] execute Cannot add or update a child row: a foreign key constraint fails (`confluence`.`#sql-3ecf_52`, CONSTRAINT `FKxxxxxxxxxxx` FOREIGN KEY (`PARENTID`) REFERENCES `CONTENT` (`CONTENTID`)) 2014-02-11 11:03:18,841 ERROR [main] [hibernate.tool.hbm2ddl.SchemaUpdate] execute could not complete schema update com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`confluence`.`#sql-3ecf_52`, CONSTRAINT `FKxxxxxxxxxxx` FOREIGN KEY (`PARENTID`) REFERENCES `CONTENT` (`CONTENTID`)) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.Util.getInstance(Util.java:381)
1 2 3 4 5 6 7 2014-02-11 11:03:18,977 ERROR [main] [atlassian.confluence.upgrade.UpgradeLauncherServletContextListener] contextInitialized Upgrade failed, application will not start: com.atlassian.config.ConfigurationException: Cannot update schema com.atlassian.confluence.upgrade.UpgradeException: com.atlassian.config.ConfigurationException: Cannot update schema at com.atlassian.confluence.upgrade.AbstractUpgradeManager.upgrade(AbstractUpgradeManager.java:111) .. Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`confluence`.`#sql-3ecf_52`, CONSTRAINT `FK6382C05974B18345` FOREIGN KEY (`PARENTID`) REFERENCES `CONTENT` (`CONTENTID`)) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

Diagnosis

Please run the query below against your database:

1 select * from CONTENT where PARENTID not in (select CONTENTID from CONTENT);

If the query above returns an empty set, you do not have to follow the steps provided in the resolution as you are not affected by the foreign key violation in Content table. If the query returns a row or more results, please proceed to the resolution. Please take note of the CONTENTIDs of the pages returned in the result.

Cause

There are pages in your Confluence that their parent page does not really exist in Confluence.

Solution

Resolution

  • Prepare a full backup of your Confluence database for any potential rollback

  • Run the query below against your database to set the

  • Please replace <contentID> with the contentIDs from the previous query in Diagnosis.

    1 update CONTENT set PARENTID=NULL where CONTENTID=<contentID>;
  • Make sure that there is no more Violations in your database by running the query from the Diagnosis, and then you can proceed with the upgrade again.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.