Repository navigation
fix(fleet-queue): claim by explicit id; pin claim lease + lane storage (#7617) - #7882
Merged
Merged
Conversation
#7617) verb_claim claimed via a subquery and re-read the result as the newest claimed row for (queue, worker_id). Every lane shares worker_id repo-worker-code, so under concurrent claims that re-read could return another lane's just-claimed task: the caller was handed a row stamped with a foreign lane_id (live repro 2026-11-08: lane code-u claims returned tasks stamped code-e and code-t), worked a task it did not own, and the claim guard could quarantine a live foreign claim. This is the writer that can release/displace a live claim named in #7617, alongside the lease contract confusion. - Pick the candidate id first, claim THAT row with a conditional UPDATE by id (status re-check keeps it atomic; a lost race re-picks), and read the claimed row back by id. - Split the lease defaults into named constants: CLAIM_DEFAULT_LEASE_SECONDS=2700 for claims, HEARTBEAT_DEFAULT_EXTEND_SECONDS=900 for heartbeats, with claim_lease_until() as the single source for the stored lease_until on both the tasks and leases rows. - Regression tests (oracle: #7617 acceptance): claim_lease_is_the_requested_lease_not_the_heartbeat_default and claim_lane_argument_is_stored_verbatim. Tests: cargo test -p fleet-queue --features queue-broker --lib claim_ -> 10 passed incl. both new tests; turso_queue suite 20 passed.
developing-today
Bot
requested review from
a team and
dezren39
as code owners
November 9, 2026 00:44
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
This was referenced Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #7617
What was wrong
verb_claim(Turso queue broker) claimed a task via a subquery, then re-read the result as "the newest claimed row for (queue, worker_id)". Every lane sharesworker_id = repo-worker-code, so under concurrent claims that re-read can return another lane's just-claimed task:lane_id— live repro this shift (2026-11-08): lane code-u claims returned task 13384 stampedcode-eand task 8500 stampedcode-t, claimed with--lane code-u;The lease contract was also one literal away from the same class of bug:
2700(claim default) and900(heartbeat extension default) were bare literals in different verbs.Fix
UPDATE ... WHERE id = ? AND status IN ('queued','parked')(status re-check keeps the claim atomic; a lost race re-picks), read the claimed row back by id. Theleasesrow insert now provably names the same task the caller is handed.CLAIM_DEFAULT_LEASE_SECONDS = 2700andHEARTBEAT_DEFAULT_EXTEND_SECONDS = 900;claim_lease_until()is the single source for the storedlease_until(tasks row and leases row), computed from one clock read withclaimed_at.Regression tests (oracle: #7617 acceptance)
claim_lease_is_the_requested_lease_not_the_heartbeat_default— stored lease is claimed_at + requested lease (2700), never + the 900 s heartbeat default; the two defaults are pinned distinct.claim_lane_argument_is_stored_verbatim— the lane passed at claim reaches the UPDATE verbatim; a lane-less claim stores NULL, never another lane's id.Verified on the laptop:
cargo test -p fleet-queue --features queue-broker --lib claim_→ 10 passed incl. both new tests; fullturso_queuesuite 20 passed. Queue task 14226.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.