Repository navigation
Description
Summary
Two related behaviours in the worker's relay session (remote-worker/internal/session/loop.go, at c13d556), found while running the E16 density experiment (rossoctl/moca-experiments, branch e16/low-duty-spec, e16/RESULTS.md):
- Silent refusal. A worker connection admits
WORKER_MAX_CONCURRENTrunning Execs plusQueueCap(64) queued Execs.enqueueAdmittedrefuses the next one with abusy: queue fullerror frame, but nothing is logged. The refusal is invisible in the worker log, and the relay does not audit it for exec-token callers. - A refusal or abort burst drops the connection. Refusals, aborts and cache replays are sent through
trySendinto a 16-slot terminal-frame reserve (TerminalReserve = QueueCap / 4). If more than 16 of those frames arrive before the sender drains,trySendfails.acceptthen returnsErrEgressWedged, and the session ends and re-dials. Every Exec in flight on that connection fails, including ones unrelated to the burst.
Evidence (AWS m7i.metal-24xl, moca worker at c13d556, WORKER_MAX_CONCURRENT=256)
The E16 driver sends one end-session Exec per resident session when a 15-minute measurement window ends, so N sessions produce N end-session Execs within about a second.
1. Refusals at exactly 320 per connection. The driver footer counts end-session Execs that failed. On every rung the failures equal N − 320 (256 running + 64 queued):
| N | end-sessions failed | N − 320 |
|---|---|---|
| 256 | 0 | — |
| 384 | 64 | 64 |
| 512 | 192 | 192 |
| 640 | 320 | 320 |
| 768 | 448 | 448 |
| 896 | 576 | 576 |
worker.log and the relay log contain no queue full or busy line for any of them.
2. The connection drops. At N=1024 (and on some runs at N=896 and N=1280), the burst also overflowed the terminal reserve. Worker log, N=1024, by second:
| second | end-sessions | aborted | VMs destroyed |
|---|---|---|---|
| 00:33:24–28 | 0–2 | 0 | 0–2 |
| 00:33:29 | 119 | 137 | 133 |
2026-11-09T00:33:29Z session: WARNING the terminal-frame reserve (16 slots) is undrained, so the terminal frame for req_id 8145070469489825 cannot be queued; treating egress as wedged and dropping the connection so the harness re-dials
2026-11-09T00:33:29Z microvm-worker: stream ended (egress wedged: the terminal-frame reserve could not be queued); reconnecting in 718ms
All 14 Execs in flight on the connection then failed with exit −1, although none of them was part of the burst. The same thing happened at N=896 (9 and 14 Execs) and N=1280 (24 and 16). With the end-session Execs paced at 50 per second instead, no rung up to N=1536 refused or wedged.
Why it matters
- Production. Many agent sessions ending or being cancelled together (a deploy, a user cancelling a batch, a harness timeout) can drop a worker's connection and fail every unrelated Exec it is running.
- Operators. Refusals at the per-connection limit leave no trace, so the cap is invisible until something else breaks.
Possible fixes (for discussion)
- Log refusals: a rate-limited line in
enqueueAdmitted(count,inflight, queue capacity), and a counter on/stats. - Make the reserve hold a burst. Options: a reserve sized for the admission limit, a blocking send with a short deadline for refusals instead of failing at once, or coalescing refusals into one frame.
- Keep unrelated Execs alive: on reserve overflow, fail only the frames that could not be queued and close the connection only if the sender is truly stuck (no progress for some time), rather than on the first full reserve.
Assisted-By: Claude Code
Activity
session: a terminal frame offered after the drainer exited is not cou…
fix(session): a refusal burst past the reserve is deferred, not a dro…