Dispatcher offers a second same-repo ticket to a host that can run only one run per repo — the leg quits in seconds and the ticket is re-dispatched every marker TTL #384

Closed
opened 2026-11-20 18:38:35 +00:00 by ben · 1 comment
Owner

What happened

2026-11-20 10:16Z–12:27Z, live fleet-wide (ADR 0009, #357). Seven Matou/policy-generators tickets became ready at once. Each of the three pool hosts started ONE and then ran for over an hour with its second heavy slot free, while the dispatcher re-dispatched the remaining tickets to that free slot every marker TTL (10 min): policy-generators #74, #76, #77, #78, #80 were dispatched 4–9 times each, #78 was first dispatched 10:22Z and first claimed 11:34Z.

Cause

swarm.yml holds a per-repo workdir lock (/tmp/matou-workdir-<slug>.lock, idss #638 / #347) across the whole run, so a host runs at most one swarm run per repo at a time. The allocator (fleet_dispatch_allocate) does not know this: it offers any ready ticket to any free slot. A second same-repo ticket sent to a host already running that repo loses the workdir lock and exits 0 in 2–3 s ("workdir … busy with another job for this repo — yielding"). Nothing claims the ticket, the marker expires, and the next pass dispatches it again — often to another host in the same state.

Evidence

  • Dispatcher log 10:18Z–11:35Z: 4–5 ready, every host 1 free, 1 busy throughout.
  • policy-generators runs 921–945: every target-host leg ran 2–3 s (e.g. run 921, #78 → matou-workstation slot 2, leg 10:22:22–10:22:26Z), while the long legs were runs 912 (workstation, 2857 s), 933 (elitebook-03), 947.
  • Ticket timelines: no swarm-claim and no agent-working on #74/#76/#77/#78/#80 until their eventual claim; re-dispatch stopped at each claim. So this is NOT #375 (a claimed ticket re-listed).

Cost

About 40 wasted dispatches (3 legs each) in two hours, and — the real cost — three heavy slots idle for over an hour with ready work queued, whenever the ready set is concentrated in one repo.

Possible directions (not decided)

  1. Allocator: do not place a ticket on a host that already holds a slot for the same repo (the slot report already carries holder.repo), and do not place two same-repo tickets on one host in one pass; QUEUE it with a reason instead.
  2. Or lift the constraint: per-run worktrees so two runs of one repo can share a host (bigger change; #347 is why the lock spans the land stage).

Option 1 keeps a slot idle when all ready work is one repo; option 2 is what actually uses the capacity. Needs a ruling.

Found by an interactive session at Ben's request.

## What happened 2026-11-20 10:16Z–12:27Z, live fleet-wide (ADR 0009, #357). Seven `Matou/policy-generators` tickets became ready at once. Each of the three pool hosts started ONE and then ran for over an hour with its second heavy slot free, while the dispatcher re-dispatched the remaining tickets to that free slot every marker TTL (10 min): policy-generators #74, #76, #77, #78, #80 were dispatched 4–9 times each, #78 was first dispatched 10:22Z and first claimed 11:34Z. ## Cause `swarm.yml` holds a **per-repo workdir lock** (`/tmp/matou-workdir-<slug>.lock`, idss #638 / #347) across the whole run, so a host runs at most one swarm run per repo at a time. The allocator (`fleet_dispatch_allocate`) does not know this: it offers any ready ticket to any free slot. A second same-repo ticket sent to a host already running that repo loses the workdir lock and exits 0 in 2–3 s ("workdir … busy with another job for this repo — yielding"). Nothing claims the ticket, the marker expires, and the next pass dispatches it again — often to another host in the same state. ## Evidence - Dispatcher log 10:18Z–11:35Z: 4–5 ready, every host `1 free, 1 busy` throughout. - policy-generators runs 921–945: every target-host leg ran 2–3 s (e.g. run 921, `#78 → matou-workstation slot 2`, leg 10:22:22–10:22:26Z), while the long legs were runs 912 (workstation, 2857 s), 933 (elitebook-03), 947. - Ticket timelines: no `swarm-claim` and no `agent-working` on #74/#76/#77/#78/#80 until their eventual claim; re-dispatch stopped at each claim. So this is NOT #375 (a claimed ticket re-listed). ## Cost About 40 wasted dispatches (3 legs each) in two hours, and — the real cost — three heavy slots idle for over an hour with ready work queued, whenever the ready set is concentrated in one repo. ## Possible directions (not decided) 1. Allocator: do not place a ticket on a host that already holds a slot for the same repo (the slot report already carries `holder.repo`), and do not place two same-repo tickets on one host in one pass; QUEUE it with a reason instead. 2. Or lift the constraint: per-run worktrees so two runs of one repo can share a host (bigger change; #347 is why the lock spans the land stage). Option 1 keeps a slot idle when all ready work is one repo; option 2 is what actually uses the capacity. Needs a ruling. Found by an interactive session at Ben's request.
Author
Owner

Settled (interactive session, at Ben's instruction). Direction 1 taken; landed on main as 5d9d752, in the running dispatcher since 2026-11-20T20:18Z (self-pin 5d9d752, service restarted).

fleet_dispatch_allocate now gives each ready ticket the first free slot on a host that is not already running a different ticket of its repo — from busy slot holders in the slot reports, the dispatcher's own placements of the last 180 s, and placements earlier in the same pass. A ticket with no eligible slot is queued with a reason naming this rule. Tests: tests/fleet-dispatch-lib-test.sh +14; full offline suite green. GOTCHAS #384, docs/journal/2026-11-20-384.md.

Not yet observed on a live same-repo burst. Direction 2 (lift the per-repo lock so the idle slot is usable) is #386.

**Settled (interactive session, at Ben's instruction).** Direction 1 taken; landed on `main` as `5d9d752`, in the running dispatcher since 2026-11-20T20:18Z (self-pin `5d9d752`, service restarted). `fleet_dispatch_allocate` now gives each ready ticket the first free slot on a host that is not already running a different ticket of its repo — from busy slot holders in the slot reports, the dispatcher's own placements of the last 180 s, and placements earlier in the same pass. A ticket with no eligible slot is queued with a reason naming this rule. Tests: `tests/fleet-dispatch-lib-test.sh` +14; full offline suite green. GOTCHAS #384, `docs/journal/2026-11-20-384.md`. Not yet observed on a live same-repo burst. Direction 2 (lift the per-repo lock so the idle slot is usable) is #386.
ben 2026-11-20 20:19:50 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/dev-factory#384
No description provided.