Unable to upgrade Confluence due to duplicated users in the database
要約
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.
環境
6.13.10
診断
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;
原因
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.
ソリューション
データベースの変更を行う場合は必ず事前にバックアップを取得してください。可能な場合は、まずステージング サーバーで SQL コマンドの変更、挿入、更新、または削除を行うようにします。
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.