Skip to content

chief host tests: a locked clock, so a spawn reply's goroutine never races the test - #1234

Merged
ZacxDev merged 2 commits into
mainfrom
fix/chief-host-test-clock-race
Dec 4, 2026
Merged

ZacxDev merged 2 commits into
mainfrom
fix/chief-host-test-clock-race

Conversation

@ZacxDev

@ZacxDev ZacxDev commented Dec 4, 2026

Copy link
Copy Markdown
Owner

CI on #1232 failed with a DATA RACE in TestChoosingTheMachineAgainNeverStartsASecondChief: the test moved its plain time.Time clock while the spawn reply of an earlier choose was still being applied on its own goroutine, which reads s.now (applyChiefSpawnReply → hostChiefSpawnWasSent).

  • chief_host_test.go: the test's clock is the package's locked outcomeClock.
  • chief_host_turns_test.go: reconcileRig returns an outcomeClock too (the same shape); TestARestartPastTheCountdownNeedsNoForce installs its clock before the choose, real time until the test fixes one, instead of reassigning s.now while that goroutine may run.

Test-only: production's s.now is time.Now.

Measured with go test -race -count=30 -run 'TestChoosingTheMachineAgainNeverStartsASecondChief|TestARestartPastTheCountdownNeedsNoForce' ./internal/api/: 3 DATA RACE reports on origin/main, 0 with this change.

🤖 Generated with Claude Code

…races the test moving it

TestChoosingTheMachineAgainNeverStartsASecondChief wrote its clock while the
spawn reply of an earlier choose was still being applied on its own goroutine
(which reads s.now). The reconcile rig and TestARestartPastTheCountdownNeedsNoForce
had the same shape. Under -race, -count=30 of the two tests: 3 DATA RACE
reports at origin/main, none with this change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ZacxDev
ZacxDev marked this pull request as ready for review December 4, 2026 13:29
@ZacxDev
ZacxDev merged commit 217a792 into main Dec 4, 2026
33 checks passed
@ZacxDev
ZacxDev deleted the fix/chief-host-test-clock-race branch December 4, 2026 14:04
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