Crowd upgrade fails with 'Duplicate entry 'xxx' for key 'app_dir_mapping_id'

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

Summary

Problem

Crowd will not start up after an upgrade. The following appears in the atlassian-crowd.log

1 2 3 4 2016-09-21 22:30:20,348 localhost-startStop-1 INFO [crowd.upgrade.tasks.UpgradeTask645IntroduceUserPermissions] Group mapping for '<somegroup>' is being added in directory 'somedirectory' 2016-09-21 22:30:20,452 localhost-startStop-1 WARN [engine.jdbc.spi.SqlExceptionHelper] SQL Error: 1062, SQLState: 23000 2016-09-21 22:30:20,453 localhost-startStop-1 ERROR [engine.jdbc.spi.SqlExceptionHelper] Duplicate entry '<somegroup>' for key 'app_dir_mapping_id' 2016-09-21 22:30:20,454 localhost-startStop-1 ERROR [jdbc.batch.internal.BatchingBatch] HHH000315: Exception executing batch [could not perform addBatch]

Diagnosis

Diagnostic Steps

Run the following SQL query to see all the groups in your Crowd instance.

1 2 3 4 5 6 7 8 9 10 11 SELECT d.directory_name, g.group_name, COUNT(lower_user_name) FROM cwd_user u LEFT JOIN cwd_membership m ON u.id = m.id LEFT JOIN cwd_directory d ON u.directory_id = d.id LEFT JOIN cwd_group g ON u.directory_id = g.directory_id GROUP BY d.directory_name, g.group_name ORDER BY d.directory_name; SELECT * FROM cwd_group; SELECT * FROM cwd_directory;

Cause

This error occurs when the default 'crowd-administrator' group does not exist in the Crowd internal directory or another internal directory that was created. A new admin group was created in the internal directory. The upgrade is trying to duplicate the group and errors.

Solution

Workaround

You can workaround this issue by following the steps below:

  1. Add a temporary Crowd administrator group into all of your internal directories where it does not exist. Name it 'crowd-administrators'.

  2. Assign all of the existing 'admin (role) group members to this newly created crowd-administrators group.

  3. Add this group to each of your Atlassian Applications, as necessary.

  4. Delete the problematic _admin_ group from your Crowd instance. This group is identified in the error above.

  5. Reattempt the upgrade process.

  6. Once you've successfully upgraded, you can execute the following SQL queries to rename back the temporary group to _admin (role) _ as desired:

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 UPDATE cwd_group SET group_name = 'System Administrator' WHERE group_name = 'crowd-administrators'; UPDATE cwd_group SET lower_group_name = 'system administrator' WHERE lower_group_name = 'crowd-administrators'; UPDATE cwd_app_dir_group_mapping SET group_name = 'System Administrator' WHERE group_name = 'crowd-administrators'; UPDATE cwd_membership SET parent_name = 'System Administrator' WHERE parent_name = 'crowd-administrators'; UPDATE cwd_membership SET lower_parent_name = 'system administrator' WHERE lower_parent_name = 'crowd-administrators';

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

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.