test(#630): use WithTestThrottler for race-window tests#816
Merged
Conversation
Tests that rely on the migration staying in CopyRows long enough for a concurrent goroutine to do its work were depending on table size for timing. On fast hardware (or when SeedRows produced fewer rows than intended, as in block#630) the migration could race past CopyRows before the goroutine finished, leading to "Condition never satisfied" timeouts or silently degraded test coverage. WithTestThrottler installs a Mock throttler whose BlockWait sleeps 1s per chunk, making the CopyRows window predictable regardless of CI load. Apply it to the five tests that were missing it but follow the same race-window pattern as TestResumeFromCheckpointE2E (which has already used the throttler successfully): - TestResumeFromCheckpointE2EWithManualSentinel — fixes block#630 - testEnumReorder / testSetReorder - testAlterPKIntToBigIntWithDML - testAlterPKIntToBigIntWithDMLAndAdditionalColumnChange - TestCheckConstraintWithDML Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
aparajon
approved these changes
May 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TestResumeFromCheckpointE2EWithManualSentinelwas finishing CopyRows before the test'scancel()arrived, so the second migration sometimes had no checkpoint to resume from and didn't reachWaitingOnSentinelTablewithin the 30sEventuallywindow. AddingWithTestThrottler()keeps it predictably slow.pkg/migration/*_test.gofor the same hazard: a goroutine waits forstatus >= CopyRowsthen runs a fixed-iteration DML loop. Five tests had this pattern without the throttler — they were relying on table size + CI hardware speed for the race window. Added the throttler to all of them so timing is bounded byBlockWait(1s/chunk) instead of row count:testEnumReorder/testSetReorder(datatype_test.go)testAlterPKIntToBigIntWithDML/testAlterPKIntToBigIntWithDMLAndAdditionalColumnChange(datatype_test.go)TestCheckConstraintWithDML(check_constraint_test.go)Tests deliberately skipped:
TestMigrationCancelledFromTableModification(DDL detection only requires< CutOver, much wider window),runCutoverAtomicityTest(throttler would defeat the cutover-race intent), and theWithDeferCutOver/sentinel-blocked tests (sentinel itself bounds timing).Test plan
go test ./pkg/migration -run 'TestResumeFromCheckpointE2EWithManualSentinel|TestEnumReorder|TestSetReorder|TestAlterPKIntToBigIntWithDML|TestAlterPKIntToBigIntWithDMLAndAdditionalColumnChange|TestCheckConstraintWithDML' -count=20🤖 Generated with Claude Code