fix(daemon): claim and fetch tasks only while the dispatcher has room #1799

Merged
sam merged 3 commits from fix/1797-claim-within-capacity into main 2026-11-08 03:53:07 +00:00
Owner

Fixes #1797.

  • taskDispatcher counts submitted tasks that haven't taken a slot yet (waiting). hasRoom() is true when limit <= 0 or active + waiting < limit.
  • claimRequeued and the NATS fetch loop in drainNATS both stop when there's no room. The rest of the backlog stays unclaimed in the store, or unfetched in the stream, until a later pass. There's still no per-claim poll wait, so the watchdog fix from 49d7619 is kept.
  • A run waiting on a callee gives its slot back, so the callee still finds room and can't deadlock.
  • Deletes the empty dispatcher.go and identity.go stubs.

Checked against the issue's open questions:

  • The worktree is created inside process, after the slot is taken. Claimed-but-waiting tasks never allocated disk, so this PR doesn't explain the disk growth. Look at volume cleanup (cleanupExpiredStorage runs only at startup) next.
  • A max_concurrency of 0 means unlimited. Check the deployed value.

Test: TestDrainPassClaimsOnlyWhatTheDispatcherCanRun runs 10 queued tasks with a limit of 2. One pass claims 2. It failed before the fix (all 10 were claimed). task check passed locally.

Still to do after deploying: unclaim or requeue the tasks currently claimed, and prune orphaned worktrees and volumes.

Fixes #1797. - `taskDispatcher` counts submitted tasks that haven't taken a slot yet (`waiting`). `hasRoom()` is true when `limit <= 0` or `active + waiting < limit`. - `claimRequeued` and the NATS fetch loop in `drainNATS` both stop when there's no room. The rest of the backlog stays unclaimed in the store, or unfetched in the stream, until a later pass. There's still no per-claim poll wait, so the watchdog fix from 49d7619 is kept. - A run waiting on a callee gives its slot back, so the callee still finds room and can't deadlock. - Deletes the empty `dispatcher.go` and `identity.go` stubs. Checked against the issue's open questions: - The worktree is created inside `process`, after the slot is taken. Claimed-but-waiting tasks never allocated disk, so this PR doesn't explain the disk growth. Look at volume cleanup (`cleanupExpiredStorage` runs only at startup) next. - A `max_concurrency` of 0 means unlimited. Check the deployed value. Test: `TestDrainPassClaimsOnlyWhatTheDispatcherCanRun` runs 10 queued tasks with a limit of 2. One pass claims 2. It failed before the fix (all 10 were claimed). `task check` passed locally. Still to do after deploying: unclaim or requeue the tasks currently claimed, and prune orphaned worktrees and volumes.
sam added 1 commit 2026-11-08 03:29:54 +00:00
sam added 1 commit 2026-11-08 03:37:54 +00:00
test(daemon): adopt go fix's promoted-field literal (#1797)
Quality / check (pull_request) Canceled after 2m32s
558659bcf4
sam added 1 commit 2026-11-08 03:45:21 +00:00
Merge branch 'main' into fix/1797-claim-within-capacity
Quality / check (pull_request) Successful in 7m24s
d70596f4bf
sam merged commit 3b67ef746f into main 2026-11-08 03:53:07 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1799