Multiple entries with same key error while syncing from external user directory
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles 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
Syncing from an external user directory shows Multiple entries with same key error in the logs. The last synchronization status at the Cog icon > Overview > User Directories page mentions: "Synchronisation failed. See server logs for details."
Environment
Bamboo 7.x versions
Related to:
BAM-20735 - Unique constraint violation while syncing an external user repository
CWD-5182 - Sync Failures due to duplicated External IDs
Diagnosis
java.lang.IllegalArgumentException: Multiple entries with same key errors can be found at the atlassian-bamboo.log
file:
java.lang.IllegalArgumentException: Multiple entries with same key:
[
id=1234,
name=newuser,
createdDate=2020-11-06 09:46:07.0,
updatedDate=2020-11-06 09:46:07.0,
emailAddress=new.user@email.com,
firstName=New,
lastName=User,
displayName=New User,
lowerName=nuser,
directoryId=123456789,
externalId=123:0ce0e16489003840a44430bf8201bba5
]
[
id=5678,
name=olduser,
createdDate=2020-03-16 13:12:03.0,
updatedDate=2020-10-30 17:46:14.0,
emailAddress=old.user@email.com,
firstName=Old,
lastName=User,
displayName=Old User,
lowerName=ouser,
directoryId=123456789,
externalId=123:0ce0e16489003840a44430bf8201bba5
]
Cause
This error is caused by a change to one or more of the following user's information in the external user directory:
- name
- first name
- last name
- email address
Solution
- Stop Bamboo.
- Backup Bamboo database.
- Get the old user id from the message found in the
atlassian-bamboo.log.
Run the following queries against the Bamboo database:
DELETE FROM CWD_USER_ATTRIBUTE WHERE USER_ID = 5678; DELETE FROM CWD_MEMBERSHIP WHERE CHILD_ID = 5678; DELETE FROM CWD_USER_CREDENTIAL_RECORD WHERE USER_ID = 5678; DELETE FROM CWD_USER WHERE ID = 5678;
Replace 5678 with the old user id found in the
atlassian-bamboo.log
- Start Bamboo back