Repository navigation
fix(test): serialise the stats tests that share the global revert map - #431
Merged
Merged
Conversation
`record_and_read` used a unique pass name to avoid racing other tests, but
`take_resets` clears the WHOLE process-global map. On a parallel test
thread the clear can land between `record_and_read`'s writes and its read,
which then sees `None`:
assertion `left == right` failed
left: None
right: Some(3)
It turned PR #428's Verification Gate red, on a PR that changes only a
workflow file. Reproduced on main: 1 failure in 400 runs of
`stats::tests --test-threads=8`. With both tests holding a shared test
lock: 0 in 2000. The lock recovers from poison, so one failing test
cannot cascade into the other.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RZof1M5HMBSYVZPeoT4MEn
Rivet verification gate✅ 30/38 passed
Filter: Failed artifacts(none) Updated automatically by |
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.
What failed
PR #428 changes only a workflow file, yet its Verification Gate went red on a Rust unit test:
Why
record_and_readwrites its own pass name three times and then reads it back. Its comment says the unique name prevents races. It doesn't:take_resetsin the same module callstake_revert_summary(), which clears the whole process-global map. When the two tests run on parallel threads, the clear can land between the writes and the read, and the read returnsNone.Evidence
stats::tests --test-threads=8mainThe counts alone don't prove the fix: one failure in 400 runs is a single observation, not a known rate. The argument rests on the mechanism. Both tests now hold one test-only lock, so the clear and the read can't interleave. The lock recovers from poisoning, so one failing test can't take the other down with it.
Is that the only race on these globals? I checked every reader of the global stats in the workspace:
take_resetsis the only test that clears the revert map.record_and_readis the only test that reads it.record_revert, and an added key can't disturb a read of a unique key.CoverageSummaryvalues and never touch the global.So the lock covers every test pair that can race.
cargo clippy --all-targets -D warningsandcargo fmt --checkare clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01RZof1M5HMBSYVZPeoT4MEn