Skip to content

fix(batch): retry Firestore contention before batch leases expire - #23915

Merged
Git-on-my-level merged 4 commits into
mainfrom
lane/wedge28
Oct 28, 2026
Merged

Git-on-my-level merged 4 commits into
mainfrom
lane/wedge28

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Wrap batch store transactions in bounded fresh-transaction retries for explicit Firestore Aborted contention and expired transaction chains. Each SDK transaction gets one attempt so the outer retry budget stays bounded.
  • Back off scheduler pulls with jitter after contention exhaustion. Protect cooldown state across overlapping pulls, and return any leases committed before a pull failure.
  • Ship retry on by default with BATCH_PIPELINE_CONTENTION_RETRY_ENABLED=false as the batch worker kill switch.
  • Add static source-site fields to batch pull, pump, and maintenance failure logs. Exception text and IDs remain out of logs.
  • Keep deterministic worker validation quarantine recoverable: the durable audio reference remains on the quarantined job, and ordered projection keeps its existing fences.

RCA evidence

The read-only census at 17:40Z found 33 of 36 wedges admitted before 16:35Z; 35 were projection obligations and one was in recovery. Sanitized worker logs from 16:30Z–17:40Z contained 504 Aborted, 128 ValueError, and 11 InvalidArgument records. The logs had no traceback frames, source sites, or messages, so the exact hot document and any poison unit remain unproven. The observer reported audio custody present for 789/789 checked units, and the source/retention contract keeps accepted audio recoverable.

Recovery proposal

No production nudge was run. If T3 projection obligations remain after the worker deployment, run the existing OIDC-protected POST /v2/batch-pipeline/reconcile on backend-integration with {"stage":"prod"} using the configured batch worker service identity. The handler performs the durable reconciliation and projection sweep. Read the observer again for T3 and custody afterward; do not edit individual job documents.

Verification

  • Targeted backend shard: 4 files, 114 tests passed through backend/test.sh and omi-heavy, under nice -n 19.
  • helm template rendered the production batch worker chart with a synthetic digest; the new environment value rendered as "true".
  • scripts/check_feature_flag_registry.py: OK.

Production deployment remains lead-owned through gcp_diarizer.yml. This PR does not merge or deploy.

Failure-Class: FC-retired-transaction-treated-as-fatal

Owns: #23915

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

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 ✅ Completed 2026-10-28T18:50:25.263809Z d8c654e 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: d8c654ea9c

ℹ️ 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 +193 to +197
return run_with_transaction_contention_retry(
lambda: client.transaction(max_attempts=1),
commit,
operation_name='batch_pipeline_store',
)

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 Keep contention retries within the scheduler lease budget

When a read-time abort or expired transaction consumes more than 120 seconds, this wrapper can retry successfully but issue an already-expired lease: Scheduler._pull_shard captures now before calling the store and every replay writes lease_until=now + LEASE_SECONDS. No retry deadline is scoped by the pump's pull path, so the helper permits multiple long transaction chains, while heartbeats start only after the entire pull returns. Unlike the previous read-time failure path, this can commit a new lease that recovery immediately expires, consuming a worker attempt without usable processing time; earlier leases in the same pull can also expire while waiting. Bound pull retries by the remaining lease budget and refresh the lease timestamp when replaying the transaction.

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 7bc941c into main Oct 28, 2026
57 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/wedge28 branch October 28, 2026 19:10
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