Skip to content

fix(server): resume dispatch after every remote drops at once instead of stalling the queue - #353

Merged
GeiserX merged 1 commit into
mainfrom
fix/overflow-stall-348
Oct 8, 2026
Merged

GeiserX merged 1 commit into
mainfrom
fix/overflow-stall-348

Conversation

@GeiserX

@GeiserX GeiserX commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

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.probe compared 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: failed marked both remotes down, then the probe ended up, as it began, so it logged nothing and called onChange for nobody. That is why the log shows the second remote.down pair with no remote.up after it, and why GET /v1/server still showed both up.

With the remotes silently up again, every queued job routed to a remote. The only things that call dispatch are 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: a Remotes with a fake fetch; a failed lands while the probe waits on GET /v1/server. On main the second remote.up and the second onChange never 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 for fast, 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:

error: expect(received).toBe(expected)
Expected: 2
Received: 1
(fail) ... Remotes: a `failed` during the probe's requests still ends in remote.up and onChange

error: expect(received).toBe(expected)
Expected: "done"
Received: "queued"
(fail) ... every remote drops in one tick while the local Worker is mid-job: the queue resumes when they return

The numbers

tests/remote-dispatch.e2e.test.ts on MacMini: 16 pass, 0 fail.

Full bun run check on 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

  • One remote dropping: its jobs go to the other remote or run here (SV-X5, SV-X6, existing tests); the other remote's job ends keep dispatching, so this never stalled, only slowed. Now the dropped one is announced back too.
  • A remote that never comes back: named jobs run here, jobs only a remote can run wait, as designed.
  • During such a stall the API reported the queue as healthy: queue.queued 572, queue.running 0, every remote up, 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

  • Bug Fixes
    • Remote servers that recover during an in-progress health check are now correctly marked as available, with recovery notifications sent.
    • Jobs returned to the queue after remote servers fail can resume when the servers recover and local work completes.

… 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.
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: GeiserX/akou/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2f6719ca-16b6-4bef-a643-194f930b8777
📥 Commits

Reviewing files that changed from the base of the PR and between dd779da and 72439e0.

📒 Files selected for processing (3)
  • docs/ux/SERVER.md
  • src/main/server/remotes.ts
  • tests/remote-dispatch.e2e.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Remote 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.

Changes

Remote probe recovery

Layer / File(s) Summary
Remote probe result flow
src/main/server/remotes.ts
A new private ask method checks the remote server and key responses, then returns available presets, installed engines, and version data. probe applies the result after the request completes and compares it with the latest remote state.
Remote recovery and queue tests
tests/remote-dispatch.e2e.test.ts, docs/ux/SERVER.md
Tests cover a remote returning to up during an in-flight probe and forwarded jobs completing after two remotes recover. The server UX declaration describes these cases.

Priority: ⬆️ High

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 72439

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)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: resuming dispatch when all remotes drop and the queue would otherwise stall.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@GeiserX
GeiserX merged commit 385a991 into main Oct 8, 2026
29 checks passed
@GeiserX
GeiserX deleted the fix/overflow-stall-348 branch October 8, 2026 02:18
GeiserX added a commit that referenced this pull request Oct 8, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant