Repository navigation
fix(batch): read each projection-finish stamping page in one BatchGet - #25287
Conversation
The one-time stamping pass (#25225) read every row of a 200-row page with its own transactional get. From an operator host that is about 17 s a page, so the roughly 527k-row production pass was a 12-hour job and the finish-backoff lever could not be turned on the same day. Read the page with one transactional get_all instead. The documents read, the transaction's conflict fence, the writes and the shared cursor are unchanged; a row deleted between the page query and the transaction still reads as empty and is skipped. An empty page issues no BatchGet. The strict Firestore test fixture now models a whole-document BatchGet as well as the folder-membership mask. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Git-on-my-level
left a comment
There was a problem hiding this comment.
RECOMMENDATION: APPROVE. This is a technical review comment, not a GitHub approval event: GitHub rejected the APPROVE action because the connected reviewer account is also the PR author.
Reviewed head e6a610e.
-
Yes. With google-cloud-firestore 2.20.0,
DocumentReference.get(transaction=tx)routes throughTransaction.gettoClient.get_all([ref], transaction=tx); this change calls that sameClient.get_allpath with the full page and same transaction. Both register the same documents with the same transaction, so the read/conflict set is unchanged (lock acquisition timing can differ). The function reads the marker and page before staging anyupdateorset. See the pinned transaction implementation, pinned client implementation, and Firestore contention/transaction semantics. -
Yes. In the pinned Python client, BatchGet maps both a found document name and a missing document name back to the original input
DocumentReference; thereforesnapshot.reference.path == ref.pathfor both. Missing documents produce snapshots withexists=Falseandto_dict() is None.projection_pagesupplies distinct document IDs, so the documented duplicate-reference elision does not omit a requested ref. On a successful completed RPC there is no expected missing map entry. If an RPC/protocol error prevents a complete result, failing before writes and leaving the cursor unchanged is the safe retryable outcome. See the pinned parser and BatchGet API contract. -
No fixed 200-read cap. Firestore documents a 10 MiB API request limit and 270-second transaction lifetime (plus 60-second idle expiry); transaction docs also list a 20-second lock deadline. The BatchGet request here carries 200 document names, and the commit stages at most 200 row updates plus the marker. Those general size/time limits still apply to unusually large rows or a slow/contentious page, but 200 itself is not a documented read-count limit. See Firestore quotas and transaction failure limits.
-
Yes. The fixture's existing folder-membership BatchGet caller still passes
field_paths=['folder_id'];Nonenow models the SDK's ordinary full-document read for this new caller. The narrowed fixture continues rejecting unsupported non-null masks. -
Yes.
stamp_pagestages the clock updates and advances the sharedaftercursor / completion marker in the same transaction. A committed page is skipped on restart; an interrupted or failed page leaves the checkpoint unchanged and is retried. This matches the runbook's per-page atomicity contract.
The focused pytest command could not run in this environment because the selected Python interpreter has no pytest module; the PR description reports 30 passing tests. No production action was taken.
…tegration (#25307) ## Why `BATCH_PROJECTION_FINISH_BACKOFF_ENABLED` is being turned on for prod backend-integration on the push captain's go (SCA-2222, SCA-2166, 2026-11-14), applied by the release executor as a config-only revision. Repo config did not declare the lever at all, so the next deploy rendered from the repo would drop it. That is what happened to five hand-set Firestore lever values at 13:45Z today (fixed by #25277). This PR makes the repo say what production is meant to run. Both conditions of the runbook's re-enable bar that could be met from code are met: - the one-time stamping pass completed at 12:46Z (read-only preview: complete, 0 missing), using #25225 and #25287; - the finish counters export from backend-integration since Train 1 (#25291): `omi_batch_projection_finish_reads_total` read 46,459 in ten minutes at 16:44Z with `omi_batch_projection_finish_completed_total` at 0. ## What changed - `backend/deploy/runtime_env/prod.overlay.yaml`: `BATCH_PROJECTION_FINISH_BACKOFF_ENABLED: 'true'` (category rollout) for `backend-integration`, which runs the finish sweep, and for `backend-sync`, which can reach the same sweep through its authenticated reconcile and batch metrics routes (review SCA-2270; its finish counters read 0 in production today, so this is consistency, not a second saving). - `backend/deploy/runtime_env.yaml`: regenerated. - `config/deployment-setting-classification.json`: the binding is classified as config. - `backend/docs/feature-flag-registry.md`: regenerated. - `backend/tests/unit/test_render_backend_runtime_env.py`: the pin moves from "absent everywhere" to "true on prod backend-integration and backend-sync, absent on every other service and environment". ## What did not change No code path. No other service: prod backend and backend-sync-backfill render an empty `BATCH_PIPELINE_WORKER_AUDIENCE`, so the authenticated reconcile route that reaches the sweep cannot be invoked on them. No dev environment. The code default stays off. ## Tests `tests/unit/test_render_backend_runtime_env.py` and `tests/unit/test_backend_runtime_env_validator.py`: 364 passed. Both generator `--check` commands pass. ## Rollout Rides the next backend train; until then the release executor's config-only revision carries the value. Proof after the flip, posted on SCA-2173: finish reads per ten minutes before and after, completions, fresh commits per ten minutes not below half the 15:12-15:42Z baseline, and no rise in over-SLA or unfinished projections. Kill switch: `BATCH_PROJECTION_FINISH_BACKOFF_ENABLED=false` restores the legacy finish page immediately. ## Product invariants affected - INV-MEM-4 Named because `backend/deploy/runtime_env.yaml` changes. This PR adds one batch-projection binding for backend-integration and touches no memory intake, consolidation, promotion or privacy TTL setting; INV-MEM-4 behaviour is unchanged. Failure-Class: FC-deploy-literal-reverts-operator-value 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…tegration The finish-backoff lever is being turned on for backend-integration, the only service that runs the projection finish sweep, now that the one-time stamping pass has completed (BasedHardware#25225, BasedHardware#25287) and the finish counters export from that service (BasedHardware#25291). Repo config did not declare the lever at all, so the next deploy would have dropped a hand-set value. Declare BATCH_PROJECTION_FINISH_BACKOFF_ENABLED=true for prod backend-integration only, regenerate runtime_env.yaml, and move the renderer pin: present and true on prod backend-integration, absent on every other service and environment. Kill switch: BATCH_PROJECTION_FINISH_BACKOFF_ENABLED=false. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Why
The one-time projection-finish stamping pass from #25225 is running in production now (started 2026-11-14 09:44Z, about 527k rows). It reads each row of a 200-row page with its own transactional
get, so a page takes about 17 s from the operator host and the pass would finish around 23:15Z.BATCH_PROJECTION_FINISH_BACKOFF_ENABLEDstays off until the pass completes, and that lever is the largest Firestore read cut scheduled for today (SCA-2173, SCA-2175).What changed
stamp_pagereads the page with one transactionalget_all(BatchGet) instead of one RPC per row.What did not change
Tests
tests/unit/test_batch_projection_finish_backfill.pyandtest_batch_projection_finish_backoff.py: 30 passed. Two new tests: one BatchGet per page inside the transaction; none for an empty page.get_allwas run with the fixture change. All pass excepttest_empty_capture_recovery.py, which fails the same 7 tests on an untouched checkout on this host (no ffmpeg).Rollout
Operator script only; no service deploy is needed for the speed-up. Kill switch for the lever itself is unchanged:
BATCH_PROJECTION_FINISH_BACKOFF_ENABLED=false.Known red, not from this change
Backend emulator proofsfails 6 cases inscripts/provider_merge_emulator_test.py(test_pl585_privacy_revoke_between_probe_and_commit_preserves_custody,test_pl584_a_predecessor_settled_after_probe_cannot_be_skipped, each on sim, emulator and postgres). This PR does not touch the provider merge path; see the check on main below.Failure-Class: none
🤖 Generated with Claude Code