Unable to upgrade Confluence due to duplicated users in the database

Still need help?

The Atlassian Community is here for you.

Ask the community


Summary

Failed to upgrade to 7.1 and onwards as the cwd_user has some duplicated records. During the upgrade, an attempt is made to add unique constraint to the table, and it eventually fails with OutOfMemoryError.

Environment

6.13.10

Diagnosis

The following error appears before the upgrade is stopped:

INFO [Catalina-utility-1] [internal.upgrade.constraint.UniqueConstraintAddition] addIfMissing Constraint [cwd_user_name_dir_id] not found on table [cwd_user]. Adding it soon.

Verify if you have duplicated records with below SQL query:

SELECT lower_user_name, directory_id, count(*) 
FROM cwd_user 
GROUP BY lower_user_name, directory_id HAVING count(*) > 1;

Cause

The unique constraint added with the following bug fix on 7.1:

As the cwd_user has large duplicated records, adding the unique constraint to the table was failed.

Solution

Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

The issue can be fixed by removing the duplicated records with the following SQL query:

DELETE FROM cwd_user 
WHERE id NOT IN (SELECT MIN(id) FROM cwd_user GROUP BY lower_user_name, directory_id);

Then, try to upgrade the Confluence again.

Last modified on Jan 20, 2021

Was this helpful?

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