How to resolve the "ERROR: integer out of range" in Charts & Graphs for Bitbucket app

This page provides a step-by-step resolution for the "ERROR: integer out of range" encountered in the Charts & Graphs for Bitbucket app.

Problem

You can encounter the following error message in the logs while using the Charts & Graphs for Bitbucket app.

ERROR: integer out of range

Cause

This error occurs when the plugin attempts to INSERT into the "AO_DA74DF_COMMIT" table, causing a BatchUpdateException during indexing. The following specific error can be seen in the logs:

ERROR [charts-and-graphs-indexing:thread-2] c.m.b.c.service.IndexJobRunner Error occurred while running IndexJobRunner for repository IOLS/discovery-service[17809] ERROR [charts-and-graphs-indexing:thread-2] c.m.b.c.service.IndexJobRunner Caught BatchUpdateException for insert into "AO_DA74DF_COMMIT" ("REPOSITORY_ID", "PROJECT_ID", "HASH", "ADDITIONS_CNT", "DELETIONS_CNT", "FILES_CNT", "COMMIT_DAY", "MERGE", "PARENTS", "AUTHOR", "AUTHOR_EMAIL", "COMMIT_DATE") values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) com.querydsl.core.QueryException: Caught BatchUpdateException for insert into "AO_DA74DF_COMMIT" ("REPOSITORY_ID", "PROJECT_ID", "HASH", "ADDITIONS_CNT", "DELETIONS_CNT", "FILES_CNT", "COMMIT_DAY", "MERGE", "PARENTS", "AUTHOR", "AUTHOR_EMAIL", "COMMIT_DATE") values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

This error usually occurs due to the sequence for generating the commit ID reaching its limit, causing the integer value to go out of range.

Solution

The "integer out of range" error can be resolved by backing up the database, clearing old commit records, resetting the sequence, and performing a dummy commit for each repository. This process ensures that the sequence for generating commit IDs starts from a valid number, allowing Charts & Graphs for Bitbucket to function properly.

  • Test these steps on your UAT/lower environments before applying them to the PROD environment directly.

  • It is suggested to take proper DB backups before doing the DB changes


The issue can be resolved by following these steps:

These steps involve changing the database, so ensure you back up the relevant data before proceeding.

Step 1: Back up the Database tables and sequences

Before making any changes, back up the following database objects to avoid accidental data loss.

  1. Back up the "AO_DA74DF_COMMIT" table.

    • This table stores commit data for your repositories.

  2. Back up the "AO_DA74DF_COMMIT_ID_seq" sequence.

    • This sequence is responsible for generating commit IDs.

Use your database management tools to export and back up these objects.

Step 2: Delete rows in the "AO_DA74DF_COMMIT" table

Run the following SQL query to delete all rows from the "AO_DA74DF_COMMIT" table. This action clears the table of any old commit records:

DELETE FROM public."AO_DA74DF_COMMIT";

Step 3: Reset the sequence to start from 1

To reset the commit ID sequence, execute the following SQL query. This will restart the sequence from the beginning:

ALTER SEQUENCE public."AO_DA74DF_COMMIT_ID_seq" RESTART 1;

Step 4: Verify the changes

After resetting the sequence, run the following SQL queries to verify that the sequence has been correctly reset:

  1. Check that the "AO_DA74DF_COMMIT" table is empty:

    The result should return 0 rows.

  2. Check the last value of the commit ID sequence:

    This query should return a value of 1, indicating the sequence is starting from the beginning.

At this point, the “Graphs” page in Bitbucket will no longer display any commits for your repositories.

Step 5: Perform a dummy commit in Bitbucket

To restore the commit data, follow these steps:

  1. Pick any repo from your Bitbucket instance.

  2. Make a placeholder commit by adding or removing a space in one of the files.

  3. Wait a few minutes (approximately five or more, depending on the repo size) to allow the system to process the commit.

  4. Refresh the “Graphs” page, and you should begin seeing the commit-graph information displayed for that repo.

  5. Perform a similar dummy commit for all other repositories. After doing so, the "Graphs" page will display commit data for each repo, and the issue should be resolved.

If the issue persists after following these steps, contact support for further assistance.