Skip to content

fix(fleet-queue): max_attempts single source of truth + quarantine recheck (#10648) - #10652

Merged
dezren39 merged 4 commits into
mainfrom
queue/max-attempts-single-source
Nov 16, 2026
Merged

dezren39 merged 4 commits into
mainfrom
queue/max-attempts-single-source

Conversation

@dezren39

@dezren39 dezren39 commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Fixes #10648. Refs #8973 (the order), #5444 (the claim guard), #6448 (the validation contract this amends), #9609 (the ceiling half of the same accident). Neither #8973 nor #5444 is closed by this PR — both carry scope beyond this defect.

The defect

Every task carries max_attempts twice: the row column and payload.max_attempts. The #5444 claim guard required the copies to agree. The #8973 creation-default alignment (d67e7bfbf, 2026-11-14) bulk-set row copies to 1000 while payload copies kept 3/4/6, and the guard quarantined tasks at claim for the split — 311 on Nov 14, 23 on Nov 15, 114 on Nov 16; 449 of the 655 blocked tasks in the 2026-11-16 blocked-pile audit trace to this one cause. Separately, 99 blocked rows already had agreeing copies again yet sat blocked forever: nothing ever re-validates a blocked row (the dep rechecker only watches dep-blocked rows; a quarantine block has no deps).

The change

One source of truth (validate.rs)

  • validate_packet no longer compares the copies. The packet/row copy governs; the payload copy is a mirror — still range-checked (1..=1000), never compared. The contract header and ceiling comment record the doctrine change and why: the Validate what you forward — one validation contract for the fleet queue's packets and verb values #6448 agreement rule assumed both copies are written once at creation, a premise the bulk row update broke.
  • task_from_packet normalizes the stored payload copy to the selected row value at enqueue, so new tasks are born aligned (skipped only if the mirror would breach the payload size ceiling — a stale mirror is harmless now, an over-ceiling payload is not).

Blocked-row re-validation (turso_queue.rs, client.rs)

  • run_quarantine_rechecks: blocked, dep-free rows whose recorded error is a claim-path quarantine are re-run through claim_guard_reason. A row whose error no longer reproduces is requeued (claim/lease cleared, recorded error discarded into an auditable unblocked event). A row still failing keeps its block, with last_error refreshed only when the current reason actually changed (no per-minute event spam).
  • Rides /sweep beside the dep rechecker (same expire timer, opt out with quarantine_recheck=false, quarantine_limit for the batch size) — chosen because the sweep is the broker's existing maintenance cadence and the dep rechecker is the direct precedent; a claim-time recheck could never see blocked rows, since claims only pick queued ones.
  • /quarantine-recheck verb + repo-queue quarantine-recheck CLI mirror the /dep-recheck shapes, including --task for a forced single-row recheck.

Tests

  • Validator: the audit's split shapes (row 1000 vs payload 2/3/4/6) validate clean and normalize; a proptest that ANY two in-range copies validate clean (oracle: the single-source-of-truth rule); the pre-existing selection test updated from the agreement doctrine.
  • Claim guard / recheck: verdict tests over the fossil shapes (split-copy fossil releases, schema-broken stays with today's reason, payload-less stays, dep-blocked/classic/non-blocked are out of scope), plus wiring oracles (route, sweep ride, client surface) mirroring dep_wiring_oracles_8276.

Live data repair (already done, ahead of this PR)

From the audit directory's repair ledger (repair_ledger.jsonl): 213 non-terminal split-copy tasks aligned (payload := row), 0 failures; 6 blocked rows whose only current blocker was this quarantine requeued after port validation; rows blocked for any additional reason were aligned but not touched further. Post-repair census: 0 mismatched non-terminal tasks. Deploy of this PR (broker build from main, both locations, rollback kept) stops the defect minting new fossils; the observation window after deploy is reported on #10648.


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

…check (#10648)

The #5444 claim guard required the two max_attempts copies (task
row + payload) to agree. The #8973 creation-default alignment
(d67e7bf) bulk-updated row copies to 1000 while payload copies
kept 3/4/6, and the guard quarantined 449 tasks for the split
(2026-11-16 blocked-pile audit, root cause #1).

- validate_packet: drop the copy-agreement error. The packet/row
  copy is the single source of truth; the payload copy is a
  mirror, still range-checked, never compared.
- task_from_packet: normalize the stored payload copy to the
  selected row value at enqueue (skipped only if the mirror
  would breach the payload size ceiling), so new tasks are
  born aligned.
- Blocked-row re-validation: rows fossilized in blocked because
  nothing re-validated them (99 audit rows already had agreeing
  copies). run_quarantine_rechecks re-runs blocked, dep-free,
  quarantine-errored rows through the claim guard and requeues
  the ones whose error no longer reproduces; it rides /sweep
  beside the dep rechecker and is exposed as /quarantine-recheck
  + repo-queue quarantine-recheck, mirroring #8276's shapes.
- Regression tests: the audit's split shapes (1000 vs 2/3/4/6)
  at the validator, a proptest that any two in-range copies
  validate clean, the claim-guard fossil verdicts, and wiring
  oracles for the new verb/sweep ride/client surface.

Refs #8973, #5444, #6448. Fixes #10648.
@dezren39
dezren39 requested a review from a team as a code owner November 16, 2026 09:05
@coderabbitai

coderabbitai Bot commented Nov 16, 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 53 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: dcb99ca8-b6f7-4306-bd70-7a48c171cea5
Commits

Reviewing files that changed from the base of the PR and between f4bf97e and 34fb028.

Files selected for processing: 3

  • pkgs/fleet/crates/fleet-queue/src/client.rs
  • pkgs/fleet/crates/fleet-queue/src/turso_queue.rs
  • pkgs/fleet/crates/fleet-queue/src/validate.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 16, 2026 •

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-16T09:11:19.907206Z
We couldn’t complete this review. Comment @codex review to try again.
34fb028 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.

Copy link
Copy Markdown
Member Author

Review of 804ad79: the verdict excludes dependency blocks and ordinary holds in the snapshot, but the release/refresh writes only guard id and status = 'blocked'. If the row is replaced by a manual hold or new dependency block after selection and still has status blocked, the stale verdict can release it or overwrite its reason. Also, release queues the row before a separate unconditional lease delete; a claim arriving between those operations could lose its new lease. Please use a conditional transition against the current quarantine identity/row version and dependency state, and ensure cleanup cannot touch a newly acquired lease (atomic write or a lease-identity guard). Add an interleaving regression for a replacement hold and a post-release claim, in addition to the pure verdict tests. Separately, a stable failing batch ordered on updated_at can occupy every sweep indefinitely; verify later eligible rows get a turn once the batch exceeds the limit. No live changes made.

@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: 804ad7934e

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

Comment on lines +5923 to +5925
let recorded = row.get("last_error").and_then(|v| v.as_str()).unwrap_or("");
if !recorded.starts_with("quarantined by claim path") {
return QuarantineRecheck::NotApplicable;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Verify that the current block originated from quarantine

If an operator repairs a quarantined task and manually unblocks it, verb_unblock preserves its quarantine last_error. Both claim paths also preserve that field, and verb_block records a new blocker in progress/result without replacing last_error. Consequently, if the worker subsequently blocks that valid task for an unrelated dependency-free reason, this check mistakes the historical quarantine error for the current block reason, and the next sweep silently releases the intentional block. Check current transition provenance, or clear/replace stale quarantine errors on those intervening transitions.

Useful? React with 👍 / 👎.

Comment on lines +6007 to +6009
"SELECT {TASK_COLS} FROM tasks WHERE status = 'blocked' \
AND last_error LIKE 'quarantined by claim path%' \
ORDER BY updated_at ASC LIMIT {limit}"

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 Advance the batch past unchanged quarantined rows

When at least 200 older matching rows remain invalid, the default sweep repeatedly selects those same rows: quarantine_recheck_one deliberately leaves updated_at unchanged when the validation reason has not changed. Any later repaired row therefore remains outside the batch indefinitely, defeating automatic recovery even though its claim guard now passes. Record a separate recheck timestamp or use a rotating cursor so unchanged invalid rows cannot permanently starve later candidates.

Useful? React with 👍 / 👎.

Comment on lines +942 to +946
// #10648: NO agreement check against payload.max_attempts.
// The packet copy (which becomes the task row) is the single
// source of truth; the payload copy is a mirror that
// task_from_packet normalizes at enqueue. A mirror that
// disagrees is stale data, not an invalid packet — under the

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 the authoritative retry limit in triage follow-ons

For a legacy triage row with max_attempts = 1000 and payload.max_attempts = 3, accepting the split and automatically releasing its quarantine now lets it reach completion without normalizing the stored mirror. However, verb_complete in turso_queue.rs still initializes a new fix follow-on's row limit from fpayload.max_attempts, promoting the stale value back into the authoritative column. The follow-on therefore receives only three attempts instead of 1000 and can fail prematurely. Update that consumer to use the source row's limit, or normalize stored mirrors before releasing these tasks.

Useful? React with 👍 / 👎.

@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, add credits to your account and enable them for code reviews in your settings.

@dezren39
dezren39 merged commit 329d624 into main Nov 16, 2026
1 check passed
@dezren39
dezren39 deleted the queue/max-attempts-single-source branch November 16, 2026 09:11
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): max_attempts split-copy quarantine — one source of truth + blocked-row re-validation

1 participant