Skip to content

Release claims whose dequeue caller was cancelled - #7

Open
janbjorge wants to merge 2 commits into
claude/code-review-bugs-vokwlk-04-skip-noop-writesfrom
claude/code-review-bugs-vokwlk-05-release-orphaned-claims
Open

janbjorge wants to merge 2 commits into
claude/code-review-bugs-vokwlk-04-skip-noop-writesfrom
claude/code-review-bugs-vokwlk-05-release-orphaned-claims

Conversation

@janbjorge

@janbjorge janbjorge commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

Stack 5/9, base #6.

A dequeue cancelled after its claim committed left the jobs IN_PROGRESS with no worker until the stale timeout. Now ops cancelled before apply are dropped, and orphaned claims are released afterwards (only if untouched since).

Tests: test_dequeue_cancelled_during_write_releases_claim (both services), test_op_cancelled_before_apply_is_dropped fail on base; test_uncancelled_dequeue_keeps_claim, test_cancelled_dequeue_does_not_release_job_heartbeated_since pass on both.

If a dequeue caller was cancelled (e.g. by a timeout) after its claim
reached storage, the jobs were committed IN_PROGRESS but the result was
thrown away. Nobody worked them or heartbeated them, so they sat idle
until the stale timeout (5 minutes by default). In GroupCommitLoop an op
cancelled while still pending was also applied anyway.

- StateQueries.release_claims(jobs): return jobs to QUEUED only if they
  are still exactly as the abandoned claim left them (IN_PROGRESS, same
  heartbeat), so a job heartbeated, acked or re-claimed since is left
  alone. Pure, never raises.
- GroupCommitLoop: drop ops whose future is already done before
  applying them; when a dequeue is cancelled while its write is in
  flight, queue release_claims for its result in the next batch.
- DirectQueue.dequeue: run the claim shielded; on cancellation let it
  finish in a tracked background task and release its jobs.

This branch has not been deployed

No deployments
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