2019-08-28 16:14:20,890 http-nio-8095-exec-927 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', 703609563597971212, 'hVtW5FElx8qNjHjM_6Kw8A', 'isOjJSE3l9_-lMf5U_zlNP__________amlyYQ', '2019-08-28 16:14:20.811+02', '2019-08-28 16:14:20.811+02', 1567001660811, 60, 589845) was aborted: ERROR: duplicate key value violates unique constraint "uk_token_id_hash"
Detail: Key (identifier_hash)=(hVtW5FElx8qNjHjM_6Kw8A) 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2019-08-28 16:14:20,893 http-nio-8095-exec-927 WARN [engine.jdbc.spi.SqlExceptionHelper] SQL Error: 0, SQLState: 23505
2019-08-28 16:14:20,896 http-nio-8095-exec-927 ERROR [engine.jdbc.spi.SqlExceptionHelper] 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', 703609563597971212, 'hVtW5FElx8qNjHjM_6Kw8A', 'isOjJSE3l9_-lMf5U_zlNP__________amlyYQ', '2019-08-28 16:14:20.811+02', '2019-08-28 16:14:20.811+02', 1567001660811, 60, 589845) was aborted: ERROR: duplicate key value violates unique constraint "uk_token_id_hash"
Detail: Key (identifier_hash)=(hVtW5FElx8qNjHjM_6Kw8A) already exists.
Location: File: nbtinsert.c, Routine: _bt_check_unique, Line: 433
Server SQLState: 23505 Call getNextException to see other errors in the batch.
2019-08-28 16:14:20,896 http-nio-8095-exec-927 WARN [engine.jdbc.spi.SqlExceptionHelper] SQL Error: 0, SQLState: 23505
2019-08-28 16:14:20,896 http-nio-8095-exec-927 ERROR [engine.jdbc.spi.SqlExceptionHelper] ERROR: duplicate key value violates unique constraint "uk_token_id_hash"
Detail: Key (identifier_hash)=(hVtW5FElx8qNjHjM_6Kw8A) already exists.
Location: File: nbtinsert.c, Routine: _bt_check_unique, Line: 433
Server SQLState: 23505
The problem described in the issue is not a bug, but expected behavior. The database prevents two parallel threads to insert the same token for a single user, which prevents some other problems from happening.
The only problem is that errors are being logged, which could cause some kind of anxiety for someone reading the logs, because it might make them think that there is something going seriously wrong. Unfortunately Crowd's architecture doesn't allow to mitigate the problem (just not print the log) for this specific error, as we are talking about different kind of messages and error codes for every JDBC driver and database supported.