Repository navigation
test(package-manager): stop the concurrency probes timing out under load - #13339
Conversation
add_resolves_package_selectors_concurrently_and_reports_in_selector_order failed intermittently during a full-suite run and passed on a re-run. Its mock handlers block on a condvar until all three latest requests have started, capped at 2 seconds, and the wait result was discarded — so a machine too loaded to dispatch the third request in time was indistinguishable from a genuine loss of concurrency, and the overlap assertion failed with nothing pointing at the real cause. Give the barrier a budget that outlasts scheduling latency on a machine running the whole suite in parallel, and record the expiry: the first handler to give up marks the barrier dead so its peers stop waiting, which keeps a real regression to one timeout instead of one per selector, and the assertion now says the requests never overlapped instead of only reporting a count mismatch. Verified by making the resolution loop sequential, which fails with that message. add_does_not_wait_for_a_slower_later_resolution_after_an_error reads the gap between a fast failing selector and a slow peer through a wall-clock deadline. 100 ms against 3 s left only ~2 s of slack for the fast path; widening the peer to 20 s and the deadline to 5 s keeps the same claim with room for a loaded machine. The mock's sleep does not delay teardown, so the longer delay costs nothing. LinkConcurrencyProbe carried the same 2-second barrier for cold_batch_links_slots_in_parallel and gets the same treatment. Closes #13328
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughConcurrency tests now use explicit 15-second overlap timeouts, track barrier expiry, and widen timing windows for slower selector failure scenarios. Virtual-directory link concurrency replaces its hardcoded overlap wait with a named timeout constant. ChangesConcurrency test timing hardening
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoFix flaky concurrency probe timeouts in package-manager tests
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (2): Last reviewed commit: "test(package-manager): describe what the..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pnpm/crates/package-manager/src/add/tests.rs`:
- Around line 127-130: Update the comment above OVERLAP_BARRIER_TIMEOUT to
accurately describe max_active as the overlap metric and the timeout as a
bounded failure guard, removing the claim that the verdict comes only from
max_active.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: df993d1e-822d-4c07-8ca6-a50d23e40242
📒 Files selected for processing (2)
pnpm/crates/package-manager/src/add/tests.rspnpm/crates/package-manager/src/create_virtual_dir_by_snapshot/tests.rs
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1. Barrier expiry race
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
…ecides The comment claimed the deadline played no part in the verdict, which stopped being true once expiry became its own assertion. Say what the budget is for, and record the std guarantee the expiry flag rests on: wait_timeout_while re-checks its predicate before reporting a timeout, so a peer arriving exactly on the deadline cannot be read as an expiry.
|
Addressed the CodeRabbit comment in 51b3783. The two Qodo bugs I am not acting on, with reasons. Barrier expiry race — not a race. Long blocked mock worker — measured, no cost. The sleeping handler does not hold the test up or consume a core: it is a Written by an agent (Claude Code, claude-opus-5[1m]). |
|
Code review by qodo was updated up to the latest commit 51b3783 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
…oad (pnpm#13339) add_resolves_package_selectors_concurrently_and_reports_in_selector_order failed intermittently during a full-suite run and passed on a re-run. Its mock handlers block on a condvar until all three latest requests have started, capped at 2 seconds, and the wait result was discarded — so a machine too loaded to dispatch the third request in time was indistinguishable from a genuine loss of concurrency, and the overlap assertion failed with nothing pointing at the real cause. Give the barrier a budget that outlasts scheduling latency on a machine running the whole suite in parallel, and record the expiry: the first handler to give up marks the barrier dead so its peers stop waiting, which keeps a real regression to one timeout instead of one per selector, and the assertion now says the requests never overlapped instead of only reporting a count mismatch. Verified by making the resolution loop sequential, which fails with that message. add_does_not_wait_for_a_slower_later_resolution_after_an_error reads the gap between a fast failing selector and a slow peer through a wall-clock deadline. 100 ms against 3 s left only ~2 s of slack for the fast path; widening the peer to 20 s and the deadline to 5 s keeps the same claim with room for a loaded machine. The mock's sleep does not delay teardown, so the longer delay costs nothing. LinkConcurrencyProbe carried the same 2-second barrier for cold_batch_links_slots_in_parallel and gets the same treatment. Closes pnpm#13328
Summary
add_resolves_package_selectors_concurrently_and_reports_in_selector_orderfailed intermittently during a full-suite run and passed on a re-run and in isolation, as reported in #13328.Its three mock
latesthandlers block on a condvar until all three requests have started, capped at 2 seconds, and thewait_timeout_whileresult was discarded. A timeout was therefore indistinguishable from "all three started": on a machine loaded enough that the third request was not dispatched within 2 s, the handlers unblocked early,max_activenever reached 3, and the overlap assertion failed with nothing pointing at the real cause.The assertion is worth keeping — it is what pins the concurrent-resolution behaviour from #13097 — so only the deadline changes:
Verified by making the resolution loop sequential (
FuturesOrderedreplaced with await-in-loop): the test fails in 15.4 s with that message, and passes again once the implementation is restored.Two more instances of the same fragile idiom, both flagged in the issue or found alongside it:
add_does_not_wait_for_a_slower_later_resolution_after_an_errorreads the gap between a fast failing selector and a slow peer through a wall-clock deadline. 100 ms against 3 s left only ~2 s of slack for the fast path; the peer moves to 20 s and the deadline to 5 s, which keeps the same claim with room for a loaded machine. The mock's sleep does not delay teardown — the test still completes in ~0.13 s — so the longer delay costs nothing.LinkConcurrencyProbe(behindcold_batch_links_slots_in_parallel) carried the same 2-second overlap barrier and gets the same budget.No changeset: test-only, nothing published changes.
Closes #13328
Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting.Written by an agent (Claude Code, claude-opus-5[1m]).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit