cells job fails with PG::NumericValueOutOfRange: ERROR: integer out of range error

Job #11295770239 failed for dfd53efa:

Troubleshooting done by GitLab Duo:

Root cause of failure

The job failed due to a PostgreSQL database error during the database seeding process. The root cause is a PG::NumericValueOutOfRange: ERROR: integer out of range error that occurred while trying to insert data into the database.

The sequence of events leading to the failure:

  1. The job was running database seeding operations using rake db:seed_fu
  2. During the seeding of merge requests (in the 10_merge_requests.rb fixture file), the system attempted to create merge requests for various projects
  3. While processing merge request creation, the code tried to check the auto_duo_code_review_enabled setting through a cascading project setting attribute
  4. This triggered a database query that attempted to use an integer value that exceeded PostgreSQL's integer range limits
  5. The database rejected the query with "integer out of range" error
  6. This caused the entire database transaction to be aborted, leading to subsequent "current transaction is aborted, commands ignored until end of transaction block" errors
  7. The seeding process failed, causing the gdk install command to fail, which ultimately caused the entire job to fail

The specific error chain shows the failure originated in the cascaded_ancestor_value method when trying to execute a database query, which then propagated up through the merge request creation service.

Example Fix

The fix would likely involve addressing the integer overflow issue in the database. Here are the most probable solutions:

  1. Database Schema Fix: Check if there's a column in the database that's defined as a regular integer type but is receiving values that exceed the 32-bit integer limit (2,147,483,647). The column may need to be changed to bigint type:
ALTER TABLE table_name ALTER COLUMN column_name TYPE bigint;
  1. Data Validation Fix: Add validation in the Ruby code to ensure integer values don't exceed PostgreSQL's limits before attempting database operations:
# Validate integer values before database operations
if value > 2_147_483_647
  # Handle the overflow case appropriately
  value = 2_147_483_647 # or raise an error, or use a different approach
end
  1. Seeding Data Fix: Review the test data being generated in the 10_merge_requests.rb fixture file to ensure it's not creating unrealistic integer values that exceed database limits.

The actual fix would require examining the specific database schema and the data being inserted to identify which column is causing the overflow. The error occurs during the cascading project setting attribute lookup, so it's likely related to project IDs, user IDs, or other numeric identifiers in the project hierarchy.