Upgrade Fails with User_Mapping Constraint Error
Symptoms
Upgrading Confluence fails. The following appears in the atlassian-confluence.log
:
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.
- Upgrade Confluence to the latest version.
If you still see the same error, shutdown Confluence and run the following SQL query to add the constraint to your Confluence database:
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
- Start Confluence again to see if that addresses the problem.
- If the issue persists rollback your Confluence database to its previous state one more time.
- Download a new Confluence archive on the same version as your pre-upgraded version.
- Install Confluence using the same database.
- Now compare the
user_mapping
table of both databases - Add or remove any missing constraints from your Confluence database so that the
user_mapping
table is exactly the same as the vanilla installation. - Try the upgrade again.