Upgrade to Confluence Fails on Bandana_Unique_Key Relation
症状
When upgrading to 4.x or above from a 3.5.x or earlier version, the upgrade fails and the following appears in the atlassian-confluence.log
:
ERROR [main] [atlassian.confluence.upgrade.UpgradeLauncherServletContextListener] contextInitialized Upgrade failed, application will not start: Upgrade task com.atlassian.confluence.upgrade.upgradetask.BandanaKeyUniqueConstraintUpgradeTask@bce3d7 failed during the SCHEMA_UPGRADE phase due to: StatementCallback; bad SQL grammar [alter table BANDANA alter column BANDANACONTEXT set not null, alter column BANDANAKEY set not null, add constraint bandana_unique_key unique (BANDANACONTEXT, BANDANAKEY)]; nested exception is org.postgresql.util.PSQLException: Error: "bandana_unique_key" relation is already existed.
診断
This occurred in Postgres database, but might occur in other databases as well.
原因
The problem is caused when the database attempts to insert a constraint called bandana_unique_key, which already exists in the schema.
ソリューション
Perform a backup of the database. Then run the following SQL command in the Confluence database before attempting the upgrade.
- Confluence をシャットダウンします。
Run this command:
ALTER TABLE bandana DROP CONSTRAINT bandana_unique_key;
This will drop the constraint, but during the upgrade it will be created again.In MySQL, "DROP CONSTRAINT" isn't a known command, so to drop that unique key use the following:
ALTER TABLE bandana DROP INDEX bandana_unique_key;