GeezerVison is showing github.com — fix(fleet): daily top-issue dispatch jobs race on shared state — same issue double-dispatched (2026-11-04: #5421) · Issue #5464 · developing-today/code
fix(fleet): daily top-issue dispatch jobs race on shared state — same issue double-dispatched (2026-11-04: #5421) #5464Labels effort/mMedium: expected under 1 day of workkind/bugSomething isn't working (prefixed form of the classic bug label)meta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/highImportant and time-sensitivestatus:donetask/triageQueue packet kind: verify, reproduce, and route this item DescriptionProblem
The two daily top-issue dispatch jobs — opencode-daily-top-issue (rotating) and opencode-daily-top-issue-code (code-dedicated) — both fire at 07:12 and share opencode-top-issue-state.json as their dedupe record. The state file is read-then-written with no atomic claim step, so when both runs select concurrently they cannot see each other.
On 2026-11-04 both jobs walked the code backlog to #5421 and launched OpenCode sessions ~22 seconds apart (sessions ses_e5e594cc7dbffeQhm3TWhSNM38 / task 9531 / tracking #5458, and ses_e5e594c5081ffeAPNQmQjGx2sC / task 9533 / tracking #5461). The later session was stood down manually (deleted via the OpenCode server API) and #5461 closed; a queue lane (task 9434, from triage 9432) was also already working the same issue, so three channels converged on one small fix.
Why it matters
Double-booking is exactly what the shared state file exists to prevent (the feeder's dedupe rule was written after the opencode#831 / queue-task-3137 double-booking). Duplicate sessions burn laptop build capacity, produce competing PRs for the same issue, and need manual cleanup.
Fix directions (any one, or combined)
- Claim before dispatch: at selection time, atomically mark the issue (e.g. apply
queue/claimed via gh and re-read to confirm this run won) before calling pm-dispatch; the loser walks to the next backlog entry.
- Stagger the two jobs so the code-dedicated job runs after the rotating job has written state (and have the rotating job skip code on days the sibling owns it, or vice versa).
- Have each job re-read the state file (and the issue's labels) immediately before the dispatch call, not only at run start.
Acceptance
- A repeat of the 2026-11-04 morning (both jobs firing the same minute with the same top backlog entry) results in exactly one dispatch; the other job records a dedupe skip.
- The dedupe check covers queue-lane claims too: an issue with a live queue fix task is not dispatched.
Acceptance criteria
- Two dispatch jobs racing on the same state cannot dispatch the same issue twice
- The claim on shared state is atomic or lock-guarded, with the losing job standing down visibly
- A test or scripted repro demonstrates the race is closed
Activitydeveloping-today commented on Nov 4, 2026 dezren39 commented on Nov 4, 2026 Intake review
- Related issues/PRs: merged PRs with this issue number in the title: none found in a merged-PR title search. No merged PR explicitly resolves this issue, so it stays open.
- Notes: Enriched by the fleet monitor (Duty 2, protocol §5): acceptance criteria appended to the body, labels normalized (kind/bug, priority/high, effort/m).
- Risks / suggested approach: This is the same double-work class the queue claim exists to prevent: the dispatch jobs need an atomic claim (or single-writer lock) over their shared state file. Risk: a lock that can wedge dispatch entirely — needs a stale-lock escape.
dezren39 commented on Nov 5, 2026 Task 10044 triage complete: issue #5464 confirmed open and un-fixed, fix scoped, implementation enqueued as task 10562. Findings: #5464 (comment)
dezren39 commented on Nov 5, 2026 Picked up by repo queue worker lane code-c as task 10562 (small_fix). Implementing the claim-before-dispatch fix scoped in the task 10044 triage: stagger the two daily dispatch jobs, add an atomic claim step before pm-dispatch, and a scripted two-run race drill.
dezren39 commented on Nov 5, 2026 Fixed — task 10562 (lane code-c, 2026-11-05)
All three scoped items from the task 10044 triage are implemented and verified:
- Stagger:
opencode-daily-top-issue-code now fires at 07:32 America/Chicago (was 07:12, same minute as the rotating sibling). The rotating opencode-daily-top-issue stays at 07:12. Verified by read-back: live job next run Fri 2026-11-06 07:32 CST, and the regenerated repo copy matches the prepared body byte-for-byte.
- Claim-before-dispatch (both job bodies): after selection, a dispatcher must atomically
mkdir a per-issue claim dir (hidden_files/opencode-top-issue-claims/<owner>-<repo>-<n>.claim) and write claimant.json — exactly one concurrent run can win a mkdir. The winner then SETS queue/claimed + work/assigned on the issue (both jobs previously only read these labels) and re-reads claim + labels; immediately before the pm-dispatch POST it re-reads the shared state file and labels again. The loser records a visible verdict=dedupe-skip line in sweep.log and walks to the next backlog entry. Queue-lane claims count as claims (skip, never dispatch). Stale escape: a claim older than 2h with no dispatched state entry may be removed and retried once, so a dead claim cannot wedge dispatch.
- Race drill:
hidden_files/dispatch-claim-fix-5464/opencode-dispatch-claim-drill.py — 8 concurrent claimants on the same issue produced exactly 1 winner / 1 dispatch and 7 dedupe skips; a pre-existing queue-lane claim also made the dispatcher dedupe-skip. Drill passes.
Prepared bodies + drill are kept in the goal workspace at hidden_files/dispatch-claim-fix-5464/; both live job bodies were applied via cron.update from that exact text (repo-copy-first house rule) and verified by projection match.
Closing as fixed: a repeat of the 2026-11-04 morning now yields exactly one dispatch, with the losing job's dedupe skip on record.
MetadataMetadataeffort/mMedium: expected under 1 day of workkind/bugSomething isn't working (prefixed form of the classic bug label)meta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/highImportant and time-sensitivestatus:donetask/triageQueue packet kind: verify, reproduce, and route this item DevelopmentNo branches or pull requestsIssue actions
|