fix(provider-node): deflake coordinator pause/stop startup race#161
Merged
Conversation
… race The coordinator run loops select over a command channel and a poll interval. tokio::time::interval fires its first tick immediately, so on the first loop iteration both arms are ready and the unbiased select picked one at random — a Pause/Stop queued right after start() could lose to that immediate tick, letting one poll run (and submit) before the command took effect. This made challenge::test_resume_after_pause flaky. Add `biased;` to the select in all four coordinators (challenge, checkpoint, replica-sync, agreement) so control commands are polled before the timer tick. Pause/Stop now deterministically take effect before the first poll, while immediate-poll-on-start is preserved when no command is pending.
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.
Problem
challenge::test_resume_after_pauseis flaky and failed on an unrelated CI run (e.g. the PR #158 hardening run):Root cause
Each coordinator's
run_loopdoes:tokio::time::intervalfires its first tick immediately. So on the first loop iteration both arms are ready, and an unbiasedselect!picks one at random. APause/Stopqueued right afterstart()could lose to that immediate tick — the loop then polls and submits once before the command takes effect, leavingmock.submittednon-empty and tripping the assertion ~50% of the time.Fix
Add
biased;to theselect!in all four coordinators (challenge, checkpoint, replica-sync, agreement) so control commands are polled before the timer tick. Pause/Stop now deterministically take effect before the first poll, while immediate-poll-on-start is preserved when no command is pending.Applied to all four because they're copies of the same loop with the same latent race; only the challenge test currently asserts in a way that catches it.
Verification
cargo test -p storage-provider-node --test coordinators→ 39/39 passcargo +nightly fmt --all→ cleancargo clippy -p storage-provider-node --all-targets --all-features -- -D warnings→ clean