Skip to content

fix(queue): expire_leases fails at-cap tasks instead of stranding them in queued (#6463) - #8157

Merged
dezren39 merged 1 commit into
mainfrom
queue/14617-6463-expire-at-cap
Nov 11, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/14617-6463-expire-at-cap

Conversation

@dezren39

@dezren39 dezren39 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

What

Implements fix shape 1 from #6463 in the Turso queue backend (pkgs/fleet/crates/fleet-queue/src/turso_queue.rs):

  • expire_leases now checks each expired claimed task against its attempt cap via a new pure expiry_disposition(attempts, max_attempts) helper.
  • A task already at attempts >= max_attempts transitions to terminal failed — worker/lease cleared, binding cleared, last_error set to lease expired at attempt cap (n/m) — with a lease_expired_at_cap event, mirroring fail_repo_task's terminal branch. It is no longer returned to queued, where the claim query (attempts < max_attempts) could never select it again.
  • Tasks below cap are unchanged: return to queued with the existing lease_expired event, and only those count toward the returned expired count.

Why

At-cap lease expiry previously stranded tasks in queued forever: unclaimable, invisible to terminal-state counts, no failed event. Measured 142/172 queued tasks at cap on 2026-11-06; a fresh census on 2026-11-10 (task 14617 verification, lane code-w) found 235 of 237 queued tasks at cap in repo-health-code-pilot.

Tests

  • New unit test expiry_disposition_fails_only_at_cap covers below/at/past cap.
  • cargo test -p fleet-queue --lib --all-features: 136 passed, 0 failed.

Still open on #6463 (not in this PR)

  • Bulk disposition of the existing at-cap queued zombies (they are already queued, so expire_leases never sees them; they remain per-task revive-eligible or can be failed in bulk as a separate operational step with the count recorded).
  • The claim-accounting question (whether a claim that never binds a session should consume attempt budget): this PR keeps claim-time accounting — attempts count claims — because the at-cap expiry path is now terminal and visible instead of silent. The earlier recommendation on the issue (unbound claims should not consume budget) stays recorded there for the fleet owner to decide with bind-tracking data.

Task 14617 · queue repo-health-code-pilot · lane code-o


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 10, 2026 13:39
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 38 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 74b8a311-98e6-48aa-a0dd-036a53070032
Commits

Reviewing files that changed from the base of the PR and between ed4b015 and edee5d6.

Files selected for processing: 1

  • pkgs/fleet/crates/fleet-queue/src/turso_queue.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-10T13:39:08.545129Z
We couldn’t complete this review. Comment @codex review to try again.
fda8083 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

…m in queued (#6463)

Re-applied onto current main by lane code-w (task 14617): the original commit fda8083 conflicted with the one-queue rework (#8097/#8217/#8234) in turso_queue.rs. Same change, composed with the current expire_leases: at-cap claimed rows (attempts >= max_attempts) transition to failed with last_error and a lease_expired_at_cap event instead of returning to a queued state the claim query can never select; sink-bound rows (#8234) keep their sink return regardless of cap. expiry_disposition helper + unit test unchanged from the original commit.

Tests: cargo test -p fleet-queue --lib --all-features -- 229 passed on this branch (4 consecutive runs; the very first run under compile load had one unidentified failure that did not recur), 236 passed on pristine origin/main.
@dezren39
dezren39 force-pushed the queue/14617-6463-expire-at-cap branch from fda8083 to edee5d6 Compare November 11, 2026 04:06
@dezren39

Copy link
Copy Markdown
Member Author

Re-applied onto current main — task 14617, lane code-w

The original commit (fda8083) no longer merged: turso_queue.rs was reworked under it by the one-queue changes (#8097/#8217/#8234), and a merge attempt conflicted in three regions, including the new sink-return path in expire_leases. Rather than resolve a ~400-line test-region conflict, the branch was reset to current main and the change re-applied as edee5d6 (force-push with lease; this is a task-owned queue branch).

Composition with current main: at-cap claimed rows (attempts >= max_attempts) now transition to failed with last_error and a lease_expired_at_cap event instead of returning to an unclaimable queued; sink-bound rows (#8234) keep their sink return regardless of cap, since the sink pick serves them under its own rule. The expiry_disposition helper and its unit test are unchanged from the original commit.

Verification (laptop): cargo test -p fleet-queue --lib --all-features — 229 passed on this branch across 4 consecutive runs (the very first run, under compile load, had one unidentified failure that did not recur in any re-run); 236 passed on pristine origin/main in a scratch worktree. The earlier Codex review of this PR failed on Codex usage limits and produced no findings; there are no unresolved review threads.

Merging under the standing criteria (targeted tests verified locally; PR CI checks remain queued in the fleet CI stall).

@dezren39
dezren39 merged commit 743476a into main Nov 11, 2026
1 of 8 checks passed
@dezren39
dezren39 deleted the queue/14617-6463-expire-at-cap branch November 11, 2026 04:07
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