Skip to content

fix(batch): scan only quarantined jobs for quarantine recovery dispatch - #24320

Merged
Git-on-my-level merged 1 commit into
mainfrom
lane/recoveryhold
Nov 2, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
lane/recoveryhold

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Why

The prod quarantine-recovery sweep logs ~75 event=batch_quarantine_recovery outcome=held lines a minute (backend-integration, 00:35–00:45Z 11-02: 744 held, 5 queued, 0 action=dispatch exception lines). These lines are not dispatch exceptions. They are the sweep's per-candidate outcome summary.

Cause: since #23932 (10-29), ProjectionSession.persist marks a committed job whose projection is quarantine-held with recovery_state=held, so the held-partial scan owns it. recovery_candidates() selects recovery_state in [held, prepared, running] without the job state. Those committed jobs fill the dispatch page, and RecoveryStore.prepare() refuses each one because state != 'quarantined'.

Measured at 00:47Z (Firestore COUNT, ro-prod, counts only):

count
recovery_state=held 5,400
… of which state=committed 5,289
… of which state=quarantined 111
quarantined prepared / running 8 / 1

At BATCH_PIPELINE_RECOVERY_DISPATCH_BATCH_SIZE=64 on the maintenance leader, one full scan takes about 72 minutes, and the cursor is per instance, so a leader change restarts it. Real quarantined units, including language-guarded ones, wait that long before getting their first recovery intent. None of the 111 has an intent today, and some have waited for up to a day. Their siblings' conversations wait with them (the T3 quarantine-held backlog). The committed-held stock grows by about 1.3k a day at the current batch share.

What

Add state == 'quarantined' to recovery_candidates(). prepare() already requires that state, so no unit that could be dispatched is dropped. All filters are equalities, so Firestore serves the query by single-field index merging: probed against prod, state==quarantined AND recovery_state IN [...] ORDER BY __name__ returned 120 rows with no index error. The sim model and the emulator sweep test now model the state.

Risk

  • Behaviour changes only for jobs that prepare() already refuses. The held-partial scan (held_candidates) is unchanged.
  • No new flag. No index, schema or data change.
  • Rollback: redeploy the previous image.

Verification

  • New unit test test_recovery_candidates_skip_committed_units_held_by_projection: it fails before the fix (1 failed, 135 passed) and passes after.
  • Through bin/omi-heavy, nice 19, with ambient GCP credentials unset, backend/test.sh ran 7 files: quarantine recovery, Firestore query shapes, outside-query contract, query contract, pipeline sim, characterization and owner drain. 824 passed, 0 failed. Layer: backend unit tests, hermetic.
  • The emulator integration test test_global_recovery_sweep_advances_past_held_pages_without_extra_query gains a committed-held row. It was not run locally (no emulator); CI runs it.
  • Deploy: a backend-integration release (the recovery sweep's maintenance leader) and the same image on serving. Lead's train.

Readout after deploy (backend-integration logs, counts only): outcome=held lines should fall from ~75/min to roughly the real held set per pass, queued should spike once as the 111 units get intents, and quarantined recovery_state=held should drain within minutes, except units held by design (cap or allowance, guarded zero-VAD).

Failure-Class: FC-batch-fault-domain-head-of-line-poison

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

Since #23932 (10-29), a quarantine-held projection marks its committed job
recovery_state=held so the held-partial scan owns it. recovery_candidates()
matched recovery_state in held/prepared/running without the job state, so
those committed jobs (5,289 in prod at 00:47Z, against 120 real quarantined
candidates) filled the dispatch page. prepare() refuses every one of them,
the sweep logged ~75 outcome=held lines a minute, and real quarantined units
waited a full scan cycle (~72 min, longer across leader changes) before their
first recovery intent.

Add state == 'quarantined' to the query. All filters are equalities, so
Firestore serves it by single-field index merging (probed against prod, no
composite index). prepare() already requires state == 'quarantined', so no
dispatchable unit is dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-02T00:59:27.615475Z
We couldn’t complete this review. Comment @codex review to try again.
42e79a5 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, add credits to your account and enable them for code reviews in your settings.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

View guided diff | Turn on auto-fix | Re-trigger cubic

@Git-on-my-level
Git-on-my-level merged commit 4e46ee8 into main Nov 2, 2026
66 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/recoveryhold branch November 2, 2026 01:13
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