Upgrade Fails Due to a Violation on CONTENT

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

Upgrade of Confluence fails.

The following appears in the atlassian-confluence.log:

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) 
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:

select * from CONTENT where PARENTID not in (select CONTENTID from CONTENT);
tip/resting Created with Sketch.

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.

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.

    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.

Last modified on Nov 12, 2018

Was this helpful?

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