Skip to content

SCA-2036: fix(batch): idle the record drain after a full page that admitted nothing - #24882

Merged
Git-on-my-level merged 3 commits into
mainfrom
lane/pipeline-drain-pacing
Nov 14, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
lane/pipeline-drain-pacing

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

What

The record drain loop has no pacing: every full page (100 rows) immediately triggers another pass. While privacy-blocked heads stayed on the page, the pass returned "blocked" and idled; #24841 moved them off, and since then any full page rescans at once even when nothing is admitted.

Change

A full page that ADMITTED nothing (every row deferred, failed or still behind its barrier) keeps the idle wait, like a privacy-blocked page. Only passes that made progress continue immediately.

  • The drain still reaches every due row (a page per idle interval); it just stops the hot rescan.
  • Kill switch: RECORD_DRAIN_IDLE_WITHOUT_PROGRESS=off restores the old behavior. It lives in config/record_drain.py with the other RECORD_DRAIN_* capacity knobs, outside flag-budget scope.

With this live, RECORD_DRAIN_PRIVACY_DEFER_SECONDS can be unset again (#24841 behavior) without the read climb.

Tests

  • tests/unit/test_record_drain_pacing.py:
    • a no-admission full page idles;
    • a page with progress continues;
    • the kill switch restores the old behavior;
    • a partial page never continues.
  • test_record_drain_privacy_defer: a fully blocked page now idles one interval, and the starved row is still admitted on the next pass.
  • Also ran test_batch_pipeline_live, test_record_drain_barrier_backoff, test_batch_record_dead_letter, test_batch_pipeline_serving, test_record_partial, test_record_gap_fill and test_replay_harness: 489 passed on the rebased head.

Review

One Luna round (blocking-only). Its blocker is fixed: a normal return can be a no-op (an unchanged partial inventory poll), so progress now counts only when the defer transaction sees the row out of record_pending. The paging/shuffle tests pin the old mode through the kill switch. lead2 ddc817: the defer stays at its default (900) meanwhile.

SCA-2036 review fix: rebased onto main (af24862981). The defer transaction now also reports dead-letter expiry, so it returns (progress, expired) — a row that left record_pending is progress, a dead-letter expiry is not, and a peer's dead-letter is not either. test_record_drain_pacing pins both.

Verify after deploy (backend-integration)

  • omi_firestore_billed_reads_by_caller_total{caller="database.batch_pipeline_store:due"} falls back to about 100/s.
  • store:get falls.
  • Record admissions per minute stay unchanged.

Failure-Class: none

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

Landing follow-up

Operator documentation now covers the default-on pacing control, its off rollback value, and the conservative 20-second idle for partial-record coordinators that admit children while their parent remains pending. See backend/docs/listen_pusher_pipeline/changes/2026-11-14-record-drain-pacing.md and the record-drain pacing contract in backend/docs/listen_pusher_pipeline.mdx.

CI on code head d1a80c8081: all eight backend unit shards and Backend Hermetic Merge Gate passed. The advisory Backend Emulator Proofs job failed the same six provider merge conformance cases already failing on main (54b960d947; run https://github.com/BasedHardware/omi/actions/runs/43578026940). The affected merge implementation and conformance tests are unchanged between that main snapshot and this PR. Deployment read-rate and admission checks remain post-deploy work.

@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-14T10:43:57.859038Z 62fa6a2 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.

@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.

All reported issues were addressed across 5 files

You’re at about 94% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].

Reply with feedback, questions, or to request a fix.

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

Comment thread backend/utils/batch_pipeline/live.py Resolved

@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: fcf606295e

ℹ️ 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 thread backend/utils/batch_pipeline/live.py Outdated
Comment on lines +576 to +578
if latest.get('state') != 'record_pending':
# The row left record_pending: it was admitted (by us or a peer).
return True

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 Count successful partial-record admissions as progress

When a full page contains partial-record coordinators, successful admissions are incorrectly classified as no progress. record_partial.drain_partial() admits child units through admit_page() while leaving the parent in record_pending, so this condition never counts those admissions. Consequently, even a fully productive partial-record page forces the 20-second idle wait in serving.py, delaying subsequent due recordings and limiting backlog throughput. Distinguish successful child-unit admissions from unchanged inventory polls rather than relying exclusively on the parent's state transition.

Useful? React with 👍 / 👎.

Comment thread backend/config/record_drain.py Resolved
Git-on-my-level and others added 2 commits November 14, 2026 05:07
…hing

Every full page rescanned immediately; with privacy-blocked heads deferred off the
page (#24841), barrier-blocked rows were re-read in waves without admission
(store:due 108 -> 431/s). A pass that admitted nothing now keeps the idle wait;
kill switch RECORD_DRAIN_IDLE_WITHOUT_PROGRESS=off.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review (Luna, blocking): a normal return can be a no-op (an unchanged partial
inventory poll), so counting every normal return made a full no-op page look
productive. Progress is now the defer transaction observing the row out of
record_pending. Paging/shuffle tests pin the old mode via the kill switch.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level force-pushed the lane/pipeline-drain-pacing branch from fcf6062 to d1a80c8 Compare November 14, 2026 10:20
@Git-on-my-level Git-on-my-level changed the title fix(batch): idle the record drain after a full page that admitted nothing SCA-2036: fix(batch): idle the record drain after a full page that admitted nothing Nov 14, 2026
@Git-on-my-level
Git-on-my-level merged commit a5125d8 into main Nov 14, 2026
66 of 67 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/pipeline-drain-pacing branch November 14, 2026 11:02
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