Skip to content

Reject heartbeats on jobs that are not IN_PROGRESS - #4

Open
janbjorge wants to merge 2 commits into
claude/code-review-bugs-vokwlkfrom
claude/code-review-bugs-vokwlk-02-heartbeat-requires-in-progress
Open

janbjorge wants to merge 2 commits into
claude/code-review-bugs-vokwlkfrom
claude/code-review-bugs-vokwlk-02-heartbeat-requires-in-progress

Conversation

@janbjorge

@janbjorge janbjorge commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

Stack 2/9, base #3.

touch() accepted a job already re-queued as stale, so the worker never learned it lost the claim. Now raises the new JobNotInProgressError, and HeartbeatManager stops on it.

Behaviour change: heartbeat() on a non-IN_PROGRESS job raises.

Tests: test_touch_queued_job_raises_and_leaves_state_unchanged, test_touch_after_stale_requeue_raises, test_heartbeat_after_stale_requeue_raises, test_heartbeat_swept_in_same_batch_raises, test_heartbeat_stops_after_real_stale_requeue fail on base; test_touch_updates_heartbeat and existing heartbeat tests pass on both.

touch() only checked that the job existed. After the stale sweep
re-queued a job, the original worker's heartbeat still succeeded: it
stamped heartbeat_at on a QUEUED job and HeartbeatManager kept beating,
so the worker never learned it had lost the claim while another worker
could pick the job up. BrokerQueue hits this by timing alone, since each
batch sweeps stale jobs before applying the heartbeats in that batch.

Raise the new JobNotInProgressError from touch() when the job is not
IN_PROGRESS, leaving state unchanged, and stop HeartbeatManager on it.

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