Skip to content

fleet-queue(fallback): contested claims age out with the lease (#6668) - #6676

Merged
dezren39 merged 2 commits into
mainfrom
queue/fallback-6668-contested-lease
Nov 7, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/fallback-6668-contested-lease

Conversation

@dezren39

@dezren39 dezren39 commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Fixes #6668 (follow-up to the #6660 triage probe cases).

Problem

In fallback mode (fleet-queue/src/fallback.rs), a contested claim never expired: fold_claim returned Contested whenever a contest was recorded and a holder existed — before and regardless of the lease-age check — and cmd_heartbeat refused a contested issue, so even a live holder could not renew. If the holder was the dead worker, nobody could ever claim the issue through the tool again.

Change

  • Contest ages out with the lease: in fold_claim, a contest older than the lease window (challenger has posted no claim for a full lease) falls through to the normal holder-activity fold — Live if the holder kept heartbeating, Stale (claimable, clean supersede) if everyone went silent.
  • Challenger release clears the contest in the fold's Release arm (holder's claim stands); releases from anyone else still change nothing (fold_ignores_non_holder_markers still passes).
  • cmd_heartbeat no longer refuses the holder on a contested issue — the holder check already gates it to the holder, heartbeating is how the holder proves it is alive, and cmd_release likewise has no contested check, so the verbs now treat Contested consistently.
  • Within-lease behavior unchanged: a live contest inside the lease window stays contested/hands-off; scan/status output shapes unchanged.
  • doc/fleet/queue-fallback-mode.md contested semantics updated.

Tests

cargo test -p fleet-queue --features client on the laptop: 40 passed, 0 failed, including 3 new fold tests for the #6660 cases:

  • fold_contest_ages_out_with_the_lease (Case 1: both silent ~100 leases → stale/claimable; inside lease → still contested)
  • fold_contest_holder_heartbeats_stay_live (Case 2: holder heartbeats after a contest → contest ages out to a live holder claim)
  • fold_contest_challenger_release_clears (Case 3: challenger release + lease expiry → claimable)

Existing fold_stale_supersede_and_live_contest still passes. cargo fmt --check clean for the touched file (one pre-existing fmt diff in untouched backoff.rs on main, left alone).

Worked by repo-worker-code lane code-z in fallback mode (queue backend down, PostgREST PGRST002) — claim/heartbeats/release are the marker comments on #6668.


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

fold_claim returned Contested whenever a contest was recorded and a holder existed, regardless of lease age, and cmd_heartbeat refused the holder on a contested issue — one stray claim from a dead challenger bricked the issue for the whole backend outage (probe cases in #6660).

Now: a contest older than the lease window falls through to the holder-activity fold (Live if the holder kept heartbeating, Stale/claimable if everyone went silent); a release from the challenger clears the contest in the fold; cmd_heartbeat no longer refuses the holder on a contested issue, consistent with cmd_release. Within-lease contest behavior unchanged. Three new fold tests cover the #6660 cases; doc/fleet/queue-fallback-mode.md updated.
@dezren39
dezren39 requested a review from a team as a code owner November 7, 2026 01:43
@coderabbitai

coderabbitai Bot commented Nov 7, 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 49 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: 668a3d46-91c5-4fee-b64c-2e56c09bcfdd
Commits

Reviewing files that changed from the base of the PR and between 207e612 and a7c2d35.

Files selected for processing: 2

  • doc/fleet/queue-fallback-mode.md
  • pkgs/fleet/crates/fleet-queue/src/fallback.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

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T01:51:15.767581Z a7c2d35 New commits
ℹ️ 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bef9ea3a79

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// through and let the holder's last activity govern — Live
// if the holder kept heartbeating, Stale (claimable) if
// everyone went silent.
if holder.is_some() && now - ts <= lease_seconds {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Refresh contest activity when a challenger claims again

When a challenger posts another claim, the Claim arm leaves the existing contested timestamp unchanged because it only records a contest when contested.is_none(). With a 1800-second lease, claims from A at t=0 and B at t=60 and t=1700 produce Stale A and claimable=true at t=1861, although B's latest conflicting claim is only 161 seconds old and landed while A was live. This prematurely allows another worker to pick up disputed work, contrary to the new requirement that the challenger remain silent for a full lease. Refresh or recompute contest activity before applying expiry.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a7c2d35: the fold now tracks challengers per-worker with each challenger's LAST conflicting claim timestamp, and a repeat claim from the same challenger refreshes its entry — a contest ages out only once every challenger has been silent for a full lease window. Covered by the new test fold_contest_repeat_claim_refreshes_and_multi_challenger (your A/B scenario: claims at t=0 / t=60 / t=LEASE-100 still fold Contested at t=60+LEASE+1). Full fleet-queue suite (--features client): 41 passed, 0 failed.

Comment on lines +465 to +467
if let Some((_, challenger, _)) = &contested {
if *challenger == ev.worker {
contested = None;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve other active challengers when one withdraws

If multiple workers post conflicting claim markers, releasing the first challenger now clears the entire contest, including other workers' unresolved claims. For example, A claiming at t=0, B at t=60, C at t=90, and B posting a release marker at t=120 yields Live A at t=180 with a 1800-second lease, despite C's fresh conflicting claim. Previously this remained contested. Track or recompute the remaining active challengers so one worker's withdrawal does not incorrectly make disputed work safe to resume.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a7c2d35: challengers are tracked individually in the fold, and a release now removes only the releasing challenger's contest (challengers.retain(...)) — other challengers' contests stand. Same new test covers your A/B/C scenario: B releasing at t=120 leaves the state Contested with challenger C. Full fleet-queue suite (--features client): 41 passed, 0 failed.

…sh and withdraw individually (#6668)

Codex review on PR #6676 (2x P2): a repeat claim from the same challenger did not refresh the contest timestamp, so a contest could age out while the challenger was still actively claiming; and one challenger releasing cleared every challenger's contest. The fold now keeps a per-challenger last-claim list: repeat claims refresh, a release removes only that challenger, and a contest stands while any challenger has claimed within the lease window. New test fold_contest_repeat_claim_refreshes_and_multi_challenger covers both; suite 41 passed.
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.

fleet-queue(fallback): a contested claim never expires — fold the contest with the lease so a dead holder/challenger cannot brick an issue

1 participant