Repository navigation
fix(batch): recovery wake releases the recovered unit past the head wait - #22878
Conversation
5% run 18: 46 of 54 post-recovery owner wakes advanced no row. The recovered unit re-enters the merge with ready_at = settle, so behind an unready earlier-captured head (a leaked-lease attempt-2/3 row) it waited out the 60 s head wait plus a maintenance tick (settled -> commit 65-86 s), and its projection then waited for the next 20 s serving sweep. The /recover-quarantine wake now passes a release set to the merge drain: the recovered unit, then up to 32 of its content's other units. When strict order, fresh-first and the head wait commit nothing, the first row in the set that is still the owner's pending, ready job commits at once (skipping the head wait and the catch-up depth hold), re-verified inside the commit transaction. The commit body, late marking, log chain and projection order are unchanged; the same wake's owner chain walk then projects it. Release commits carry recovered_release: true and log event=batch_merge outcome=recovered_release with closed labels. Kill switch BATCH_PIPELINE_RECOVERED_MERGE_RELEASE_ENABLED (default on; false restores the head wait and depth hold for recovered units). Registry row has a ramp block. testing/recovered_release_scenario.py replays the run 18 shape (multi-unit catch-up contents, leaked leases, empty-ASR recovery, the production wake): recovered settled -> commit p95 50-73 s -> 0 s across seeds. The gate's quarantine -> projection p95 is unchanged while leaked leases persist (409/439/602 s), because content-sibling completion behind the leaked heads dominates; it falls to 22-51 s without leaks, where release trims seed 3 from 51 to 25 s. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 285b964b2c
ℹ️ 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".
| if entry is None and release and recovered_merge_release_enabled(): | ||
| # Recovery wake: commit the recovered unit (then its content's | ||
| # ready siblings) now instead of after the head wait or the depth | ||
| # hold. Run 18: 46 of 54 wakes advanced no row; held recovered | ||
| # units waited 65-86 s for the head wait plus a maintenance tick. | ||
| segment = self._next_release(key, release) | ||
| if segment is not None: | ||
| try: | ||
| entry = self.store.run(lambda tx: commit(tx, exact=segment)) |
There was a problem hiding this comment.
Run the expired head-wait release before recovered release
When an unready head has both an older ready row whose head wait has expired and a newly recovered later row, this block commits the recovered row before the head-wait logic below can select the earliest ready row. The older row is then appended afterward as late_capture, changing the result-log and projection order even though it was already eligible; this contradicts the stated precedence that recovered release runs only when the head wait commits nothing. Move this fallback after the head-wait attempt so an already-releasable row retains capture order.
Useful? React with 👍 / 👎.
| entry = self.store.run(lambda tx: commit(tx, exact=segment)) | ||
| except BatchPrivacyBlocked: | ||
| # A fence refuses only this row; strict order commits nothing here. | ||
| release.pop(0) | ||
| entry = None | ||
| released.clear() |
There was a problem hiding this comment.
Continue past a rejected release candidate
If the pre-read candidate becomes committed or otherwise ineligible before this transaction re-verifies it, commit(...) returns None without removing it from release; a privacy rejection removes it but still leaves entry as None. In both cases Serving.drain_owner immediately breaks, discarding the local release set, so later ready siblings never receive the promised bypass and fall back to the ordinary head wait or depth hold. Continue through the remaining release candidates after a rejected exact commit rather than returning the same sentinel used to stop the drain.
Useful? React with 👍 / 👎.
…th hold, single wake) Grok review round 1 of #22878: - The missing fresh-first index fallback retried commit_next without the release set, so a wake that hit it never released the recovered unit. The retry now keeps the set. - Only the recovered unit itself passes the catch-up depth hold; its content siblings keep it, so one wake cannot push up to 33 catch-up rows past the cap ahead of a later fresh row. Both still skip the head wait. - A committed release row is popped at once instead of re-read next call. - The run 18 replay now models production's single /recover-quarantine reconcile carrying the owner wake (the sim handler's no-argument reconcile becomes that wake) instead of a second reconcile. Results are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bcba5c8717
ℹ️ 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".
| # quarantine and recovery) passes the catch-up depth hold; | ||
| # its content siblings keep it, so a wake cannot pile up to | ||
| # 33 rows past the cap ahead of a later fresh row. | ||
| released['recovered'] = current.get('recovery_state') == 'recovered' |
There was a problem hiding this comment.
Restrict depth bypass to the triggering recovered unit
When multiple units from the same content have independently recovered, a sibling in this release set also has recovery_state == 'recovered', so this condition lets every such sibling bypass the catch-up depth cap. A single wake can therefore append many catch-up rows beyond the configured cap and push a later fresh row farther back, contrary to the intended one-unit exception; identify the segment that triggered the wake explicitly rather than treating any recovered sibling as that segment.
Useful? React with 👍 / 👎.
What
The post-recovery owner wake (
/recover-quarantine→reconcile(owner_id, recovered)) now releases the recovered unit at once. It passes a release set to the merge drain: the recovered unit, then up to 32 of its content's other units. When strict order, fresh-first and the head wait commit nothing, the first row in that set that is still the owner's pending, ready job commits. It skips the 60 s head wait and the catch-up depth hold, and the commit transaction re-verifies it. The same wake's owner-chain walk then projects it.recovered_release: trueand logevent=batch_merge outcome=recovered_release source= head_state=(closed labels, no IDs).BATCH_PIPELINE_RECOVERED_MERGE_RELEASE_ENABLED, default on;falserestores the head wait and depth hold for recovered units. The registry row has arampblock.Why (5% run 18, T0 2026-10-20 13:51Z, ro-prod aggregates)
action=owner_chain outcome=summary) advanced 0 rows.ready_atset to its settle time. Behind an unready, earlier-captured head, which in run 18 was alwayshead_state=leased(80 of 80head_wait_bypasslines), it waited out W=60 plus a maintenance tick. Settled → commit was 65–86 s for every held unit. Projection then waited for the next 20 s sweep.Honest scope
This removes the recovered unit's own merge wait. It does not by itself bring run 18's gate p95 (322 s) under 300 s.
ready_atoncomplete). So the siblings could never start their own bypass.Sim (
python -m testing.recovered_release_scenario, run 18 shape)The shape is three catch-up owners with 6–9-unit contents, 10% leaked first-attempt leases, 15% empty-ASR recovery, and the production wake. Values are quarantine→projection p95 in seconds (the gate metric), with recovered settle→commit p95 in brackets, for seeds 1/2/3.
ready_at)ready_atVerification
BACKEND_UNIT_TEST_FILE_LIST=<list> nice -n 19 bash backend/test.shover the following, all passing:test_batch_pipeline_recovered_release.py(10)test_recovered_release_sim.py(3)test_batch_pipeline_owner_chain_projection.pytest_batch_pipeline_merge_head_wait.py,test_batch_pipeline_merge_head_wait_sim.pytest_batch_pipeline_merge_fresh_first.pytest_batch_pipeline_serving.pytest_fresh_latency_sim.pytest_pipeline_sim_scenarios.pyscripts/check_feature_flag_registry.py: OK.Rollout
On by default, with a kill switch. Ramp: 5% run 19 → 25% → 50% → 100% by 2026-10-24, expanded by the two-lane lead session. Clean metric: hash-cohort quarantine→projection p95 ≤ 300 s,
recovered_releaselines present, no new chain or privacy errors.Failure-Class: FC-batch-fault-domain-head-of-line-poison
🤖 Generated with Claude Code