Repository navigation
fix(runner): wait after an empty or refused claim - #16
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
e7574b3 to
4e48bc1
Compare
|
Useful load-shedding fix; CI/CD run 45743205264 shows the Rust test gate ran successfully. However current main 103ffaf is five commits beyond merge base 8807647, so please rebase and rerun. Strengthen the 3-second wall-clock tests: the allowed 1..6 claim count permits multiple retries before the intended 3s delay; use deterministic timing or assert minimum inter-claim interval, verify genuine long polls do not receive extra delay, and consider bounded jitter for synchronized fleet retries. Hold merge until fresh CI and review. |
Symptom: when the server answers a claim with "nothing for you" at once instead of holding the call about 25 s, the claim loop calls it again immediately. Every linked machine hammers the API, and each pass also starts a token process. Cause: src/runner/mod.rs, run_loop, the ClaimPoll::Empty arm only dropped the permit and looped. Fix: time each claim. An Empty claim that came back in under 1 s (HELD) waits RETRY_WAIT (3 s) before the next, the same wait the error arm already used, now one named constant. No state is carried between passes, the permit is released before the sleep, and a claimed run is not delayed. Testing: runner test with the mock answering empty at once, expecting 1 to 5 claims in 3 s. On main's loop it saw 17683 claims; with the fix it passes. The test really sleeps 3 s (tokio test-util is not enabled here). Risk: low. A new job can wait up to 3 s longer when the server answers empty at once; a long-polling server is unaffected. How to revert: git revert this commit.
Symptom: when the server answers every claim with 403 or 404, the claim loop re-registers the machine and mints a new key on each pass with no pause. Cause: src/runner/mod.rs, run_loop, the ClaimPoll::Forbidden arm waited only when the re-mint failed; after a successful re-mint it went round again at once. Fix: sleep RETRY_WAIT after a successful re-mint, as the other arms do. Testing: runner test with a test-only mock switch that answers every claim 403 (key minting still succeeds), expecting 1 to 5 claims in 3 s. Before the fix it saw 12; after, it passes. lib 379 passed, clippy -D warnings clean, filesize ok. Risk: low. A machine whose claim key is refused waits 3 s before retrying. How to revert: git revert this commit.
|
Rebased onto
|
4e48bc1 to
05df364
Compare
What a customer would see. When the server answers the claim call at once (an empty answer, or a 403/404), every linked machine calls the claim endpoint in a tight loop. Each pass of the 403/404 case also re-registers the machine and mints a key; each pass of the empty case also starts a token process.
Cause.
src/runner/mod.rs,run_loop, in the claimmatch(about lines 436-470 on main):ClaimPoll::Emptyonly dropped the permit and looped.ClaimPoll::Forbiddenslept only when the re-mint failed; after a successful re-mint it went round again at once.Fix. One fixed wait, the one the error arm already used, now a named constant
RETRY_WAIT(3 s).HELD) waitsRETRY_WAIT. A held long poll does not wait.RETRY_WAIT.Tests (each really sleeps 3 s; tokio
test-utilis not enabled in this crate):an_instantly_empty_claim_waits_before_the_next), expects 1 to 5 claims in 3 s. On main's loop: saw 17683 claims. With the fix: passes.a_refused_claim_waits_before_the_next), same bound, using a small test-only mock switch (refuse_claims). Before the fix: saw 12 claims. With the fix: passes.cargo test --lib: 379 passed.cargo clippy --all-targets -- -D warnings: clean.cargo test --test filesize: ok.Not tested. A real linked machine. Whether the live API ever answers empty at once (the only evidence is the test mock).
cargo fmt --check(rustfmt not installed on the build machine).Found in review of #13. Reviewed by a second agent; its findings are applied in this version. Nothing merged; production is Zach's call.
Risk. Low. Up to 3 s extra before the next claim after a fast empty or refused answer; a long-polling server is unaffected.
How to revert. Revert the two commits, or close this pull request.