Bitbucket - DataStoreException: A database error has occurred - index contains unexpected zero page at block

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

An operation fails (perhaps in the UI) and the following (or something similar) is seen in the logs:

1 2 3 4 5 XXXX-XX-XX XX:XX:XX,XXX ERROR [http-nio-7990-exec-74] X555555 *<request_ID> <user> <ip>,<ip> "POST /projects/<proj>/repos/<repo>/pull-requests HTTP/1.1" c.a.s.i.w.pull.PullRequestController Exception occurred com.atlassian.bitbucket.DataStoreException: A database error has occurred. ... Caused by: java.sql.BatchUpdateException: Batch entry 7 insert into bb_pr_commit (commit_id, pr_id) values ('<hash>', <value>) was aborted: ERROR: index "idx_bb_pr_commit_commit_id" contains unexpected zero page at block <block_num> Hint: Please REINDEX it. Call getNextException to see other errors in the batch.

Environment

Postgres

Cause

Index has become corrupt in Postgres DB.

Solution

  • Implement a maintenance window

  • Perform full backup of database for safety

  • Shutdown any application connected to the database

  • Reindex the index as the Postgres database hints

  • Start applications and ensure the issue has been resolved

In this case it is best to confer with a DBA but the actual SQL used thus far (and in the case of the example above):

1 REINDEX INDEX idx_bb_pr_commit_commit_id;
Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.