Skip to content

[AI-3663] Re-slot the sync_hash migration after staging's goose version - #2422

Closed
kanat wants to merge 3 commits into
mainfrom
kanat/ai-3663-reslot-sync-hash
Closed

kanat wants to merge 3 commits into
mainfrom
kanat/ai-3663-reslot-sync-hash

Conversation

@kanat

@kanat kanat commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Why

#2302 merged 20270201001200_connector_router_sync_hash.sql after staging's global goose version was already 20270202000000 (applied by an older build from main). goose.NewProvider is built without WithAllowMissing (acceleration/internal/store/migrate.go:97), so any build from main refused to start on staging: goose reports a migration older than the newest applied one as missing.

The change

  • git mv the file to 20270202000100_connector_router_sync_hash.sql: newer than 20270202000000, older than the open PRs' 20270301000900+. Content unchanged.
  • The two comments that name the file (connector_definition.go, router_config.go) point at the new name. No other reference to the old version existed.
  • Both statements are ADD COLUMN IF NOT EXISTS, so a database that applied it under the old version runs it again as a no-op (goose records 20270202000100 next to the old row).
  • New test TestTheSyncHashMigrationSortsAfterAGlobalVersionStagingHad: a database at 20270202000000 has no sync_hash column; with the old row and the columns present, Migrate succeeds and records 20270202000100.

Checks

  • go build ./..., go vet ./..., go vet -tags integration ./... in acceleration/: clean.
  • Store migration tests (-tags integration, own test database, both suites): pass, including the new test and TestMigrateIsIdempotent (fresh database).
  • Mutation: moving the file back to 20270201001200 fails the new test (the columns exist at 20270202000000).

🤖 Generated with Claude Code

kanat and others added 2 commits November 24, 2026 23:15
#2302 merged 20270201001200 after staging's global goose version was already
20270202000000, and goose is built without WithAllowMissing, so a build from main
refused to start there. Rename it to 20270202000100; both ALTERs are
ADD COLUMN IF NOT EXISTS, so a database that ran it under the old version
re-runs it as a no-op.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@kanat kanat left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: GO

Reviewed at dcbab46 (already contains current main). CI: CodeQL, labeler and GitGuardian pass; go and integration are skipped while the PR is a draft and run at ready.

Checked and sound:

  • goose v3.27.3 treats as missing only a file older than the newest applied version that is not applied. An applied version with no file is ignored, and checkHistory refuses only unknown versions older than the squashed one. A database that ran the file under its old version therefore starts.
  • Two builds against one database: a build from before #2302 migrates it to 20270202000000, then a build from current main is refused (missing 20270201001200). That is the staging stop. This head then starts and records 20270202000100, and the build from before #2302 still starts on the result. A database first migrated by current main (old version applied) starts on this head and gets 20270202000100 as a no-op. A fresh database migrates. Builds from main between #2302 and this PR cannot start on a database migrated by this head, but no release tag contains #2302.
  • Content unchanged, expand-only (ADD COLUMN IF NOT EXISTS). schema/global.sql holds no version, and no other file refers to the old version.
  • Mutations of the new test: the file back at the old version, the file at a version between the two, and ADD COLUMN without IF NOT EXISTS each fail it.
  • TestEveryHotTableIsReadByIndex fails the same planner subtests on base and on head when run locally one after the other, so this PR does not cause it.

One Nit, inline. It does not block the merge.

Verdict: approve (GO).

s.Require().NoError(err)

s.Require().NoError(db.Migrate(s.ctx))
s.True(hasColumns())

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Nit] R1.1 This asserts the two columns the test added by hand at line 155, so it holds whatever Migrate does. Drop it, or assert the staging path: a database at 20270202000000 with no sync_hash columns and no old row has both columns after Migrate.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9f064dc: the old-row case no longer asserts the hand-added columns; a new case TestTheSyncHashMigrationAddsTheColumnsToAGlobalDatabaseAt20270202000000 starts at 20270202000000 with no columns and no old row and asserts Migrate adds both. Mutation (migration body replaced by SELECT 1): the new test fails, the old assertion passed.

…e at 20270202000000

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@kanat

kanat commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Closing: #2420 (AI-3799, merged as 015271b) made the same re-slot to 20270202000100, and its migration uses ADD COLUMN IF NOT EXISTS, so a database that ran it under 20270201001200 applies it again as a no-op. The two tests here pin that one historical slot only; staging's goose order is checked by the deployer before each tag. Nothing else in this PR is left to land.

@kanat kanat closed this Nov 25, 2026

@kanat kanat left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: GO

Delta round 2 on 9f064dc (previous reviewed dcbab46). The delta is test-only: acceleration/internal/store/migrate_test.go.

R1.1 (Nit): fixed. The old test keeps only the recorded-row check after Migrate. The new test TestTheSyncHashMigrationAddsTheColumnsToAGlobalDatabaseAt20270202000000 starts at 20270202000000 with neither column and asserts Migrate adds both columns and records 20270202000100.

Mutations:

  • Migration Up body replaced by SELECT 1;: the new test fails (migrate_test.go:162), the old test passes. Restored.
  • ADD COLUMN IF NOT EXISTS changed to ADD COLUMN: the old-row test fails with SQLSTATE 42701 on the re-run (migrate_test.go:152). The new test passes. Restored.

Checks: -run TestStoreSuite -testify.m SyncHash passes 2/2 on head and 2/2 on head merged onto origin/main 32f4de2. go vet -tags integration ./internal/store/ is clean.

The full store package times out in Redis tests on head and on current main alike (machine load 35-46). It is not caused by this PR and does not block this delta.

CI: draft, so the integration and go jobs are skipped; Analyze, CodeQL, labeler and GitGuardian pass.

Details: scratchpad/2422/reviewer-2.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant