Repository navigation
fix(server): resume dispatch after every remote drops at once instead of stalling the queue - #353
Conversation
… of stalling the queue A probe compared a remote's state with a snapshot taken before its two requests. When a job's long-poll timed out while the probe was out, `failed` marked the remote down, the probe then ended `up` as it began, and it logged nothing and called `onChange` for nobody. Every queued job routed to a remote that nothing would ever dispatch to: on 2026-10-07 both remotes timed out in one tick while the local Worker was mid-job, and from its end the server sat with 572 queued, 0 running and both remotes shown up until a restart. The probe now compares against the remote's state as it ends, so a remote marked down during a probe is announced up again and the queue is dispatched. Two tests pin it: one on `Remotes` with a `failed` landing mid-probe, one end to end with two stand-in remotes that drop in the same tick while a job runs here.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughRemote probes now collect offer data through a private method and apply results using the remote state at probe completion. Regression tests cover remote state notifications and queued job completion after remote recovery. ChangesRemote probe recovery
Priority: ⬆️ High Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The change makes dispatch resume when every remote drops at once and then comes back, so the queue no longer stalls until a restart. Regression tests cover both reported scenarios. No merge-blocking risk was found; confirm the full check passes before merging. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
…patches again when they return (#355) On 0.6.3 a primary with remotes could stop dispatching for good after every remote timed out in the same moment (the probe compared against a snapshot taken before its requests, saw no change, and announced nothing). #353 fixed it; this release ships it, together with the nightly fetch-timeout fix (#352) and the G6 fp32 record (#350). Sets every version file to 0.6.4 (`scripts/stamp-version.ts --set 0.6.4`) and adds the 0.6.4 changelog section. `stamp-version.ts --check --tag v0.6.4` passes. The tag is pushed after the merge.
The problem
On 2026-10-07 at about 22:30 both remotes behind the mini's server timed out in the same tick. The mini marked both down and took their four jobs back. From 22:31 on nothing started again: 572 queued, none running, the process alive at 0% CPU, the 30 s probe still running, both remotes shown up and idle. The owner restarted the server at about 00:30.
The cause
Remotes.probecompared a remote against a snapshot taken before its two requests. The long-polls of the four jobs timed out while that probe was in flight:failedmarked both remotes down, then the probe endedup, as it began, so it logged nothing and calledonChangefor nobody. That is why the log shows the secondremote.downpair with noremote.upafter it, and whyGET /v1/serverstill showed both up.With the remotes silently up again, every queued job routed to a remote. The only things that call
dispatchare a submit, a probe change, a remote job's end and a config save. The local Worker's job ending only pumps the local queue, and the pump skips jobs routed to a remote. No submit came after 21:49, so nothing ever dispatched again. The job store confirms it: the four returned jobs still carry their remote and remote job id, 572 queued, 0 running.The fix
The probe now compares against the remote's state as it ends, so a remote marked down during a probe is announced up again and the queue is dispatched. The probe's two requests move to
ask; nothing else changes. Overflow (#340) keeps working as before: a named job still runs here while every remote is busy.The tests
Both red on main, green with the fix, in
tests/remote-dispatch.e2e.test.ts:Remotes: a failed during the probe's requests still ends in remote.up and onChange: aRemoteswith a fake fetch; afailedlands while the probe waits onGET /v1/server. On main the secondremote.upand the secondonChangenever come.every remote drops in one tick while the local Worker is mid-job: the queue resumes when they return: a primary with two stand-in remotes named forfast, overflow on, concurrency 1, a gated local decode. Six jobs: two per remote, one running here, one queued. With a probe of each remote in flight, every long-poll answers 503; both go down, the four jobs are queued again; then both answer again. On main the five waiting jobs stay queued with both remotes up, the incident's shape. With the fix all six end done.Red output on main:
The numbers
tests/remote-dispatch.e2e.test.tson MacMini: 16 pass, 0 fail.Full
bun run checkon MacMini with the pinned Bun 1.4.2: 3141 pass, 34 skip, 7 fail across 238 files in 1528 s. The 7 are in six files none of which touch remotes or dispatch (dictation pill, dictation audio, live setup, Qwen review, the benchmark's ps check, the Docker Hub login script), and all 154 tests of those six files pass when run alone on the same box, so they are the mini's load during the full run. GitHub CI on the PR is green on all three OSes, ci-ok included.Checked beside it
queue.queued572,queue.running0, every remoteup, no flag. Not changed here; with the fix the state cannot arise from this cause.No version or changelog change: the 0.6.4 release is separate.
Summary by CodeRabbit