Upgrade Fails with User_Mapping Constraint Error

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

Note that this KB was created for the Data Center version of the product. Data Center KBs 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

Upgrading Confluence fails. The following appears in the atlassian-confluence.log:

1 2014-07-16 12:06:40,841 ERROR [main] [atlassian.confluence.upgrade.UpgradeLauncherServletContextListener] contextInitialized 1: StatementCallback; SQL [alter table user_mapping drop constraint user_mapping_unq_lwr_username]; 'user_mapping_unq_lwr_username' is not a constraint.; nested exception is java.sql.SQLException: 'user_mapping_unq_lwr_username' is not a constraint.

Cause

A previous upgrade failed and the database was not rolled back properly to its pre-upgrade state, which caused some inconsistency on the user_mapping table.

This behaviour affects users that are under Confluence version 5.3 and try to upgrade to 5.3 or later.

Resolution

We recommend testing this resolution in a staging/development instance before applying it in production. And before applying in production, be sure to backup your database.

  1. Upgrade Confluence to the latest version.

  2. If you still see the same error, shutdown Confluence and run the following SQL query to add the constraint to your Confluence database:

    1 2 3 4 5 ALTER TABLE [dbo].[user_mapping] ADD  CONSTRAINT [unq_lwr_username] UNIQUE NONCLUSTERED ( [lower_username] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] GO
  3. Start Confluence again to see if that addresses the problem.

  4. If the issue persists rollback your Confluence database to its previous state one more time.

  5. Download a new Confluence archive on the same version as your pre-upgraded version.

  6. Install Confluence using the same database.

  7. Now compare the user_mapping table of both databases

  8. Add or remove any missing constraints from your Confluence database so that the user_mapping table is exactly the same as the vanilla installation.

  9. Try the upgrade again.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.