Upgrade to Confluence Fails on Bandana_Unique_Key Relation

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.

Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles 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

Symptoms

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.

Diagnosis

This occurred in Postgres database, but might occur in other databases as well.

Cause

The problem is caused when the database attempts to insert a constraint called bandana_unique_key, which already exists in the schema.

Resolution

Perform a backup of the database. Then run the following SQL command in the Confluence database before attempting the upgrade.

  1. Shutdown Confluence
  2. 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;
    

Last modified on Dec 30, 2024

Was this helpful?

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