Upgrade fails due to missing CONTENT_PERM_SET entry
During the upgrade attempt, The following appears in the
2013-09-02 14:13:48,663 ERROR [main] [atlassian.confluence.upgrade.UpgradeLauncherServletContextListener] contextInitialized Upgrade failed, application will not start: Upgrade task com.atlassian.confluence.upgrade.upgradetask.UserKeyReferenceUpgradeTask@763a493f failed during the SCHEMA_UPGRADE phase due to: StatementCallback; SQL [UPDATE CONTENT_PERM SET USERNAME = COALESCE((SELECT um.user_k ey FROM user_mapping um WHERE CONTENT_PERM.USERNAME = um.lower_username), CONTENT_PERM.USERNAME), CREATOR = COALESCE((SELECT um.user _key FROM user_mapping um WHERE CONTENT_PERM.CREATOR = um.lower_username), CONTENT_PERM.CREATOR), LASTMODIFIER = COALESCE((SELECT um .user_key FROM user_mapping um WHERE CONTENT_PERM.LASTMODIFIER = um.lower_username), CONTENT_PERM.LASTMODIFIER)]; Cannot add or upda te a child row: a foreign key constraint fails (`confluence`.`CONTENT_PERM`, CONSTRAINT `FKBD74B31676E33274` FOREIGN KEY (`CPS_ID`) REFERENCES `CONTENT_PERM_SET` (`ID`)); nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationExceptio n: Cannot add or update a child row: a foreign key constraint fails (`confluence`.`CONTENT_PERM`, CONSTRAINT `FKBD74B31676E33274` FO REIGN KEY (`CPS_ID`) REFERENCES `CONTENT_PERM_SET` (`ID`))
This error is is caused by a different problem than the one detailed in Upgrade to 3.5.x or Higher failed Due to Duplicate Permissions. The error for that problem is:
Cannot delete or update a parent row: a foreign key constraint fails, whereas the error for our problem is:
Cannot add or update a child row: a foreign key constraint fails.
This is caused by a missing entry in CONTENT_PERM_SET table.
- Restore Confluence to the pre-upgrade state.
Run this query to find the problematic rows in parent (CONTENT_PERM_SET) and child (CONTENT_PERM) table. In this case, a single row in CONTENT_PERM doesn't have a corresponding entry in CONTENT_PERM_SET.
select * from content_perm where cps_id not in (select id from content_perm_set)
ID CP_TYPE USERNAME GROUPNAME CPS_ID CREATOR CREATIONDATE LASTMODIFIER LASTMODDATE 13795380 View ldally (null) 884739 ldally 2011-02-21 10:24:08 ldally 2011-02-21 10:24:08
Having found this row, we now need to delete it:
delete from content_perm where id = <id_of_row_found_earlier>
In our example, this would be:
delete from content_perm where id = 13795380
This delete will have no effect on your instance's permissions, as this permission has no effect on your instance prior to deletion, as the information about what content it actually effects is contained in the CONTENT_PERM_SET table, so this permission has no way of knowing what content it was meant to be attached to.
- Attempt the upgrade again.