Repository navigation
Replace rerun_of column with new bigint version - #9401
Conversation
f91870f to
7ec2955
Compare
|
Going to merge this after #9402 is resolved. I should rebase on master as well to get the changes from that PR. |
7ec2955 to
3540db2
Compare
There was a problem hiding this comment.
Pull request overview
This PR migrates the rerun_of column in the builds table from integer to bigint to support build IDs that exceed the PostgreSQL integer limit (2^31-1). The migration strategy renames the existing column to rerun_of_old and creates a new rerun_of column as bigint, allowing both columns to coexist during the transition period. All queries are updated to use COALESCE(rerun_of, rerun_of_old) to check both columns.
Key Changes:
- Database migration to rename
builds.rerun_oftorerun_of_oldand create new bigintrerun_ofcolumn - Updated all SQL queries to check both
rerun_ofandrerun_of_oldcolumns using COALESCE - Added MaxInt32 optimization logic to avoid checking
rerun_of_oldwhen values exceed integer limits - Incidental code cleanups including removing unused parameters, simplifying conditionals, and modernizing Go loop syntax
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
atc/db/migration/migrations/1765921815_rerun_of_bigint.up.sql |
Adds migration to rename old rerun_of column and create new bigint version with updated indexes |
atc/db/migration/migrations/1765921815_rerun_of_bigint.down.sql |
Provides rollback migration (contains issues with non-existent indexes) |
atc/db/versions_db.go |
Updates queries to use COALESCE for both rerun_of columns and adds MaxInt32 optimization logic |
atc/db/pipeline.go |
Updates LoadDebugVersionsDB to check both rerun_of columns |
atc/db/job.go |
Updates job queries and adds MaxInt32-based query optimization for rerun counting |
atc/db/build.go |
Updates build queries to handle both rerun_of columns during migration |
atc/db/build_factory.go |
Updates build factory queries with COALESCE for rerun_of columns |
atc/db/listener.go |
Moves context creation earlier in loop and adds cancel before return (introduces context leak) |
atc/db/component_factory.go |
Removes redundant error check after QueryRow() |
atc/db/migration/migration.go |
Simplifies else-if condition to else |
atc/db/migration/parser.go |
Removes unused migrationContents parameter from determineMigrationStrategy |
atc/db/migration/*_test.go |
Modernizes loop syntax using Go 1.22+ range over integers |
atc/db/migration/migration_test.go |
Updates to use strings.SplitSeq with range iteration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
48682ce to
aa4422b
Compare
Signed-off-by: Taylor Silva <[email protected]>
Signed-off-by: Taylor Silva <[email protected]>
* removed unused func param * remove redundant nil check in if-else Signed-off-by: Taylor Silva <[email protected]>
no point in referencing the rerun_of_old column if the build id is larger than math.MaxInt32 Signed-off-by: Taylor Silva <[email protected]>
if there's an error with QueryRow() it'll be returned by scanComponent() Signed-off-by: Taylor Silva <[email protected]>
an edge-case, but avoids accidently leaking the context Signed-off-by: Taylor Silva <[email protected]>
aa4422b to
0a1e848
Compare
|
Performed all the same manual tests I did in #9402 and everything worked. |
Changes proposed by this PR
closes #8499 and #9029
rerun_oftorerun_of_oldin thebuildstablererun_ofwith type bigintrerun_of_oldis used and create copies of the indexes referencing the newrerun_ofcolumnNotes to reviewer
Tldr of the issue was that once your build id's surpassed the size supported by
intin Postgresql, trying to re-run a build with an id larger thanintwould fail because thererun_ofcolumn was of typeint.See the comments in #8499 which explains why we went this route. Tldr: shipping long-running migrations in an OSS project is hard.
TODO
Migration-level test that I can add? As-is, the db and scheduler tests are passing. I think I can add some tests inDeciding to skip this, doesn't seem to result in long-term value IMOatc/db/migration