Error "duplicate key value violates unique constraint "pk_repository_access"" occurs in Bitbucket Server logs

robotsnoindex


Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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

A database error similar to duplicate key value violates unique constraint "pk_repository_access" occurs in the Bitbucket Server logs, potentially repeatedly.

Environment

Bitbucket Server or Data Center of any version

Diagnosis

The <BitbucketHome>/log/atlassian-bitbucket.log file shows an error such as the following:

2022-07-04 11:00:25,910 ERROR [https-jsse-nio-8201-exec-37] username *1OTT051x660x1167503x4 1upwues 128.28.52.10,130.39.32.36 "GET /projects/PROJ/repos/repo/browse/file HTTP/1.1" o.h.e.jdbc.spi.SqlExceptionHelper Batch entry 0 insert into repository_access (last_accessed, repository_id, user_id) values (1656903625885, 14259, 45766) was aborted: ERROR: duplicate key value violates unique constraint "pk_repository_access"

Often this error is logged repeatedly. You may find that the username in that log message is often or always the same, and the user is actually a service or bot user that is used for automated or programmatic access to data in Bitbucket Server.

Cause

This log message is typically the result of concurrent access to a repository by a Bitbucket Server user used in automation or CI/CD solutions, leading to a race condition which attempts to write a row to the database that was already written.

Solution

This log message can safely be ignored as long as the username in the log message is one of a non-human user used in automation. If the username is one of a human user, contact Atlassian Support for analysis.

Last modified on Mar 14, 2025

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.