Repository navigation
fix(check): serve runs waiting for a slot first come, first served - #1886
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 23 minutes. View limit details
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 |
|
CodeRabbit's review was rate-limited ("Review limit reached"), so no CodeRabbit review ran on this PR. The reviews below stand in for it; this PR changes CI admission behaviour, so it also waits for the maintainer's real review. omo-native-code-reviewer (three rounds): final APPROVE, no blockers. Resolved findings: test free port ranges now cover the ticket ports; ordering is proven by time, not port (the earlier waiter holds the higher port; a probe between them sees only the earlier one ahead); the early queue check no longer hides same-checkout and resource refusals (a run's first try meets its claims first); messages say when queued runs caused a refusal; |
|
Merge pass, before review: this PR conflicts with main in |
|
Plan change under merge focus: instead of waiting for #1872, I'll push this branch rebased on current main (it already includes #1884 and #1885) as soon as its Also in the rebased head: the first CI run here failed the two "check CLI teardown" tests at 90 s, and that was a real interaction with the queue, not only the missing #1884. The fixture's throwaway checks used the shared default lock range, so on a busy runner host they waited behind every real run holding a ticket. They now use a private lock base (reproduced with a stand-in ticket on a private |
2394210 to
5d02701
Compare
|
Merge pass review of 5d02701. Under the maintainer's rule this is reviewed by Codex Sol, the omo code reviewer, and the merge pass's QA. The code review is still running; any findings it adds will follow. Codex Sol fails it on three P2 defects: 1. A ticket lookup can block admission indefinitely (
2. A retry can hide a same-checkout conflict until the timeout (
3. A backward clock step reverses FIFO order (
Holds
|
|
Merge pass, code review result (omo-native-code-reviewer): PASS. It probed real
A peer that accepts and never answers cost about 2 s per round. That is bounded, unlike Codex finding 1, where the peer keeps sending. The three Codex P2 findings above still need a fix before merge. |
A herdr-backed check waiting for a slot could wait out all of CHECK_WAIT_SECONDS and be refused while newer runs got slots ahead of it: #1863's "Browser regression (other scripts)" waited the full 2400 s for one of the P620's 3 slots and exited 1 with no test failing. acquireWaiting asked acquire again every 2 s, and acquire gave a free slot to whichever run reached the admission port first. A run refused as busy now takes a ticket, its place in the queue: a port above the admission port (QUEUE_TICKETS of them) that answers when the run first found the PC busy. Under the admission port, acquire refuses a run that wants a slot while a run with an older ticket waits; a run without a ticket comes after every ticket. A ticket is a listening port, so a run that dies leaves no place behind, and the runner containers of a host already share that loopback for the slots. The ticket goes when the run is admitted, refused for good or out of time; a run that finds every ticket taken waits without one and tries again each round. Older checks ignore tickets; nothing breaks while both run. MAX_LOCK_PORT drops by QUEUE_TICKETS. A waiting run (acquireWaiting's retries, with a ticket or without one when all were held) with an older run ahead of it is refused before it takes the admission port, and asked again under it (a run's first try meets its checkout and resource claims first, so a second run in its checkout is still refused as such at once): one that held the port only to find the queue would keep the head out of it, round after round (a livelock found in review). acquireWaiting takes the clock and the wait between rounds as seams, so the tests drive every round: a freed slot goes to the run that waited, not to one that arrives after it; two waiters are served in the order they first found the PC busy, whichever asks first; the place goes when the run stops waiting; a run still waits when every ticket is held; a run behind the head never takes the admission port. The earlier waiter holds the higher ticket port, so only the time can order them. Ordering by port only, dropping the check before the admission port, making it apply to every run, or the queue itself each fail a named assertion. The tests' free port ranges now cover the ticket ports, so a waiting run elsewhere on the loopback cannot come ahead of a test's run. A refusal by queued runs says so instead of blaming the run limit. Merge-pass review fixes: a ticket lookup has an absolute 1.5 s deadline and drops a listener that does not answer like a ticket (one that kept talking held the admission port indefinitely); a waiting run reads its checkout and resource markers before the queue order, so a same-checkout or resource conflict is refused at once; a new ticket ranks after every live ticket whatever the clock says (a clock stepped back reversed the order), and tickets are taken one run at a time on a ticket desk port above the admission port, so two runs taking places at once cannot miss each other; a run that finds the desk taken waits for it (up to 3 s) instead of a whole round, in which a later run could take a place first. The check CLI tests' throwaway runs now use a lock range of their own: on the shared one they waited in line behind every real run waiting for a slot (with a stand-in run waiting on a private lock base, the old fixture fails after 90 s as in this PR's first CI run; the new one passes in 0.7 s). Fixes #1881
5d02701 to
1e5bd74
Compare
|
Pushed 1e5bd74 (was 5d02701). It fixes the three Codex P2 findings the merge pass raised:
Known limit, documented in a code comment: a ~10 ms window at the desk handoff, where runs that reach the desk together may swap order. Closing it would need a second queue. Sol accepted this as the remaining P2, and it closed findings 1, 2 and the clock bound. Reviews of this delta: omo-native-code-reviewer APPROVE, with all LOWs applied except an optional test hook. Tests:
The rebase onto main merges cleanly. #1872 also touches |
|
Merge pass, Codex Sol re-check of 1e5bd74: the three earlier P2s are fixed, but there is one new P2 regression. Fixed
New P2: the ticket-desk wait can run past
The merge pass re-checks the fix, looking only at the changed range. |
|
Fixed the new P2 in ce89824. The ticket desk no longer waits past
|
|
Merge pass review-work report. Overall: PASSED. Under the maintainer's rule, a check-tooling behaviour change is reviewed by Codex Sol, the omo code reviewer and the merge pass's QA.
What was checked
Follow-ups (LOW):
All required checks are green and no review thread is open. CodeRabbit did not review this PR (rate-limited or skipped). The reviews above stand in for it. |
Fixes #1881.
What failed
A herdr-backed
bun run checkwaiting for a slot could wait out all ofCHECK_WAIT_SECONDSand be refused while newer runs got slots ahead of it. #1863's "Browser regression (other scripts)" (run 40096402408) waited the full 2400 s for one of the P620's 3 slots, held in turn by runners 2, 6, 7, 8 and 12, and exited 1 with no test failing.Root cause
acquireWaitingaskedacquireagain every 2 s, andacquiregave a free slot to whichever run reached the admission port first, whether it had waited 40 minutes or arrived a moment ago. Nothing recorded who had been waiting, so under steady load a waiting run could lose every round.Fix: a first-come-first-served queue on the shared loopback
QUEUE_TICKETS= 24 of them) that answers when the run first found the PC busy. A ticket is a listening port, so a run that dies leaves no place behind, and the runner containers of a host already share that loopback for their slots (confirmed with lane ci-p620-max: one loopback network per host, one queue per host).acquirerefuses a run that wants a slot while a run with an older ticket waits; a run with no ticket comes after every ticket.acquireWaiting's retries) with an older run ahead of it is refused before it takes the admission port, and asked again under it. One that held the port only to find the queue could keep the head out of it round after round (a livelock Codex found in review, also for waiters left without a ticket when all 24 are held). A run's first try meets its checkout and resource claims first, so a second run in the same checkout is still refused assame-checkoutat once.MAX_LOCK_PORTdrops byQUEUE_TICKETS. Messages say when queued runs, not the run limit, caused a refusal.CHECK_HOST_MAX_RUNS) still queue in one line, so a head that does not fit yet holds back a later run that would.Proof (deterministic, no sleeps)
acquireWaitingtakes the clock and the wait between rounds as seams; each test drives every round explicitly:same-checkoutat once while runs wait;Mutations, each failing a named assertion: order by port only; the early check dropped; the early check for every run;
retryignored; the queue disabled. The slots tests: 32 runs, 4 at a time, 0 failures. The existing "stops waiting at its deadline" test now runs on the seams instead of a real 60 ms, and the tests' free port ranges cover the ticket ports.Reviews
codex exec, four rounds): the livelock (P2) and the overflow-waiter starvation (P2) are fixed; final round: no findings.bun run check fast: passed (6398 pass, 0 fail). CI behaviour change inscripts/check.ts: a real review is needed.