Race step follow-ups: litestream v0.5.18, activator test cleanups open
claude agent, operated by paul@keymail.devdriven by paul@keymail.devsession 92eadb57 · claude-code/2.1.321 · DOCS-T1
LLM
Follow-ups from the targeted -race CI step (branch race-helpers, Go code-health batch 3, #1123). internal/activator and internal/lease are not in the step yet:
internal/lease: a real race in a production dependency. litestream v0.5.14's Store.Close closes the database while its own snapshot monitor is still reading it. v0.5.18 fixes it. Moving to v0.5.18 changes production replication, so it needs its own branch and review; lease can then join the race step.
internal/activator: 45 tests restore a timing knob in cleanup while their wake is still running. This is a test problem: production never changes those knobs. Recommended fix: make the tests wait for their wakes before cleanup, which leaves production code alone. Activator can then join the race step.
claude agent, operated by paul@keymail.devdriven by paul@keymail.devsession 92eadb57 · claude-code/2.1.321 · DOCS-T1
Activator -race: stopped under stopping rule 2. Branch race-activator-1249, tip fb49b811, is parked and not merged. It is tests plus one counter nobody in production waits on, so v0.39.0 does not depend on it.
Invariant (fault family): every goroutine that reads a package-level timing setting must finish, with a happens-before edge, before a test restores that setting.
Round 1, P1: an excluded lease watch could launch readers after the join. Fixed: the join waits for a working watch, ends parked ones, and waits on Service.leaseWork.
Round 2, P1: a subtest restores a package-wide setting while its parent's parked watch is still alive. A lease timer can wake that watch, and its kill reads roleEmptyBound during the restore. The same applies to a subtest's own Service built before its first restoreKnob.
Astra approved the census units for this tip (type Service, Service.residentLeaseShort, the internal/activator envelope) and raised no P2 or P3.
Choices for Paul:
Refuse up front (recommended; Astra agrees). restoreKnob fails a subtest that overrides a setting while a Service built outside it is alive. Those overrides move to the parent test, whose cleanup joins everything.
State the invariant in one place. Move the timing settings into per-Service configuration, fixed at construction, with a guard test. This removes the race class but touches production code and many tests.
Cut it. Leave internal/activator out of the -race step and close this part of #1249.
claude agent, operated by paul@keymail.devdriven by paul@keymail.devsession 92eadb57 · claude-code/2.1.321 · DOCS-T1
CI on the parked tip fb49b811 failed in the gate step, so the branch is not green either. TestSwapReleaseRefusedByRootAbandons reports "a Service's lease watch was still running 10s after the test ended" (shard internal_activator@2). endLeaseWatches only reaches watches through a.entries, so a watch on an entry that has left that map is never ended. I have not confirmed that this is the path this test takes. Whichever choice is made above has to account for it. main is unaffected: nothing from this branch has merged.
claude agent, operated by paul@keymail.devdriven by paul@keymail.devsession 92eadb57 · claude-code/2.1.321 · DOCS-T1
Paul, 2026-11-19 06:3xZ: OK to choice 1, refuse up front. restoreKnob fails a subtest that overrides a setting while a Service built outside it is still alive, and those overrides move to the parent test, whose cleanup joins everything. The build also has to fix the CI failure on fb49b811 (TestSwapReleaseRefusedByRootAbandons: a lease watch still running 10 s after the test). Building now on race-activator-1249; Astra reviews; it is round 3 of 3.
claude agent, operated by paul@keymail.devdriven by paul@keymail.devsession 92eadb57 · claude-code/2.1.321 · DOCS-T1
Round 3 (3579a282, merged with main as 71470f23) was Astra READY, but its CI race step then found a real race of the same family: TestTakeBoundOnAFirstWake/aninstance starts its own goroutine (hataketest.go:504) whose production read in awaitWake (activator.go:2094) has no happens-before edge to the setKnob restore (knobrestore_test.go:96). The goroutine had finished, so the stack join passed, and syncWithServices assumes every reader ends by taking a.mu, which this path does not.
Paul, 2026-11-19: "1 is good": fix it and run a fourth and final Astra round. The fix makes tests wait for the goroutines they start before settings are restored, and sweeps the package for others like it.
claude agent, operated by paul@keymail.devdriven by paul@keymail.devsession 92eadb57 · claude-code/2.1.321 · DOCS-T1
MERGED as 037f435 (2026-11-19 12:5xZ). internal/activator is in the CI -race step (8 shards). Astra round 4 READY AFTER FIXES; the P2 (guard misses starters used as values, aliased imports, context.AfterFunc) was applied. Branch CI green on every step at b32f94cc, on top of main a6bbbf52. On the way the guard caught two untracked goroutines that arrived with the region HA storage-generations commit (TestHAWakeDoesNotWaitForRetirement); both now use goTracked. Left on #1249: internal/lease stays out of -race until litestream v0.5.18.
claude agent, operated by paul@keymail.devdriven by paul@keymail.devsession 95f33cc2 · claude-code/2.1.321 · DOCS-T1
Flake after 037f4355 (activator joins -race): main CI on a980e15 failed only in the race step, in internal/activator TestARetiredRunsFailedStopIsSettledBySweeps/attached: 'testing.go:1464: TempDir RemoveAll cleanup: unlinkat /tmp/TestARetiredRunsFailedStopIsSettledBySweepsattached.../005/zdd: directory not empty' (CI log around 14:39:20Z, 2026-11-19). a980e15 doesn't touch the activator. It looks like something is still writing into the test's temp dir while cleanup runs. Rerun queued (job 6791) by the v0.40.1 release session.