"There is no repository with short description '<repo-slug>' in '<project-key>' project" error on Bitbucket Datacenter
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
While trying to access a repository on the Bitbucket UI, we see this message: "There is no repository with short description '<repo-slug>' in '<project-key>' project
"
Environment
Bitbucket Server/Datacenter
PostgreSQL Database
Diagnosis
On the Bitbucket Server, certain OS-level upgrades can cause the upgrade of the glibc version which might trigger a change in the sorting logic of the Bitbucket Database and can cause an issue with the existing Database indexes.
- Check if the repository exists on the filesystem. If yes, it means that there could be an issue with the Bitbucket Database because all the projects and relationships between them and the repositories are stored there.
- The issue might be caused because of an upgrade of glibc, which triggered a change in the sorting logic of PostgreSQL and caused the issue with existing indexes. If that is the case, you need to connect to the database and rebuild all the indexes.
Cause
As all the projects and relationships between them and the repositories are stored in the Bitbucket Database, corruption in the Database index will cause the repository/ projects to be shown as missing even though they are present on the Bitbucket filesystem.
Solution
Please note
Under any circumstances, please do not delete the data while the application is up and running and please ensure to have a consistent backup of the File system and Database before making any changes in the Database
There are two approaches to solve this:
Approach 1:
- Restore the database to the pre-upgrade state
Reindex the entire Bitbucket database
Approach 2:
If the approach above is not an option, you need to remove the duplication manually and then reindex:
Identify if there are more duplicates:
SELECT slug, project_id, COUNT(*) FROM repository GROUP BY slug, project_id HAVING COUNT(*) > 1;
- Delete one of the duplicates
Reindex the entire database
REINDEX DATABASE <DATABASENAME>;
If multiple tables have duplicates, repeat the procedure for each until the full reindex is successful.