Crowd application logs display "Duplicate key value violates unique constraint 'uk_token_id_hash' error messages"

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

Crowd application logs display messages related to a duplicate key error when inserting a record in the table cwd_token:

atlassian-crowd.log

1 2 3 4 2020-08-31 12:49:27,070 http-nio-8095-exec-184 ERROR [jdbc.batch.internal.BatchingBatch] HHH000315: Exception executing batch [java.sql.BatchUpdateException: Batch entry 0 insert into cwd_token (directory_id, entity_name, random_number, identifier_hash, random_hash, created_date, last_accessed_date, last_accessed_time, duration, id) values (-1, 'jira-sso', 1746888137086717727, 'iiH8D8QKe870wPTXutR43g', 'J1RPQLcknVRpOggENbjVU___________amlyYS1zc28', '2020-08-31 12:49:27.057000+00', '2020-08-31 12:49:27.057000+00', 1598878167057, 60, 11438428) was aborted: ERROR: duplicate key value violates unique constraint "uk_token_id_hash" Detail: Key (identifier_hash)=(iiH8D8QKe870wPTXutR43g) already exists. Location: File: nbtinsert.c, Routine: _bt_check_unique, Line: 433 Server SQLState: 23505 Call getNextException to see other errors in the batch.], SQL: insert into cwd_token (directory_id, entity_name, random_number, identifier_hash, random_hash, created_date, last_accessed_date, last_accessed_time, duration, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

Environment

Crowd Server

Diagnosis

No side-effect is perceived on the application. The only symptom is those log messages.

Cause

The cwd_token table is responsible for holding session information about users logged in Crowd. Whenever a user logs into Crowd, a new hash is inserted in that table to control the session timeout.

Those error messages don't point to an application error. It means that Crowd has just created a new session token for a user or an integrated application which have just authenticated, and it is trying to insert the token in the database. The database then rejects the insertion because the "new" token violates a unique constraint on the token's identifier hash column.

Crowd will just acknowledge that someone was faster, the contents of the cwd_token table have changed, and will reuse another existing token that someone has inserted since they are equivalent. Because Crowd recovers from the failed insertion, this error does not cause any request to fail.

Solution

We have two alternatives regarding those messages. We can either:

  • Ignore it, since it will not harm users or applications; or

  • Change the session storage to In-memory, instead of Database, as documented in Session configuration

Updated on March 17, 2025

Still need help?

The Atlassian Community is here for you.