Details
-
Bug
-
Resolution: Won't Fix
-
Medium
-
None
-
5.7.1
-
None
Description
In Confluence 5.7 we migrated the information from the ATTACHMENTS table to the CONTENT table. However if there are entries on the ATTACHMENTS where the pageid is not on the CONTENT table the upgrade will fail with the following error:
2015-03-27 13:30:53,281 ERROR [localhost-startStop-1] [atlassian.confluence.upgrade.UpgradeLauncherServletContextListener] contextInitialized Upgrade failed, application will not start: Upgrade task com.atlassian.confluence.upgrade.upgradetask.attachmentceo.AttachmentToCeoConversionUpgradeTask@2b2e536b failed during the SCHEMA_UPGRADE phase due to: PreparedStatementCallback; SQL [insert into CONTENT(CONTENTID, CONTENTTYPE, TITLE, PAGEID, CREATOR, CREATIONDATE, LASTMODIFIER, LASTMODDATE, VERSIONCOMMENT, VERSION, PREVVER) select ATTACHMENTID, ? as CONTENTTYPE, TITLE, PAGEID, CREATOR, CREATIONDATE, LASTMODIFIER, LASTMODDATE, ATTACHMENT_COMMENT, ATTVERSION, PREVVER from ATTACHMENTS where ATTACHMENTID >= ? and ATTACHMENTID <= ?]; Cannot add or update a child row: a foreign key constraint fails (`confluence`.`CONTENT`, CONSTRAINT `FK6382C0598C38FBEA` FOREIGN KEY (`PAGEID`) REFERENCES `CONTENT` (`CONTENTID`)); nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`confluence`.`CONTENT`, CONSTRAINT `FK6382C0598C38FBEA` FOREIGN KEY (`PAGEID`) REFERENCES `CONTENT` (`CONTENTID`)) com.atlassian.confluence.upgrade.UpgradeException: Upgrade task com.atlassian.confluence.upgrade.upgradetask.attachmentceo.AttachmentToCeoConversionUpgradeTask@2b2e536b failed during the SCHEMA_UPGRADE phase due to: PreparedStatementCallback; SQL [insert into CONTENT(CONTENTID, CONTENTTYPE, TITLE, PAGEID, CREATOR, CREATIONDATE, LASTMODIFIER, LASTMODDATE, VERSIONCOMMENT, VERSION, PREVVER) select ATTACHMENTID, ? as CONTENTTYPE, TITLE, PAGEID, CREATOR, CREATIONDATE, LASTMODIFIER, LASTMODDATE, ATTACHMENT_COMMENT, ATTVERSION, PREVVER from ATTACHMENTS where ATTACHMENTID >= ? and ATTACHMENTID <= ?]; Cannot add or update a child row: a foreign key constraint fails (`confluence`.`CONTENT`, CONSTRAINT `FK6382C0598C38FBEA` FOREIGN KEY (`PAGEID`) REFERENCES `CONTENT` (`CONTENTID`)); nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstra
Since those entries are not making any references to a existing PAGEID in CONTENT our upgrade should ignore those instead of returning that error.
Environment
At current moment we only had reports from customer using mysql instances hitting on this.
Work Around:
- Restore your Confluence instance to a state prior the upgrade.
- Once you confirm you Confluence is working fine, shut down Confluence.
- Run below queries in order against Confluence database:
DELETE FROM IMAGEDETAILS WHERE ATTACHMENTID IN (select ATTACHMENTID FROM ATTACHMENTS WHERE PAGEID NOT IN (SELECT CONTENTID FROM CONTENT));
And:
DELETE FROM ATTACHMENTS where PAGEID NOT IN (SELECT CONTENTID FROM CONTENT);
This will remove any entries that are not bound to any page.
- Try upgrading Confluence.