Skip to content

fix(batch): recovery wake releases the recovered unit past the head wait - #22878

Merged
Git-on-my-level merged 3 commits into
mainfrom
fix/batch-recovered-merge-release
Oct 20, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
fix/batch-recovered-merge-release

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

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.

  • Unchanged: the commit body, late marking, log chain, watermark and projection order. Rows outside the release set keep their own head wait. An unready or fenced row is dropped from the set.
  • Telemetry: release commits carry recovered_release: true and log event=batch_merge outcome=recovered_release source= head_state= (closed labels, no IDs).
  • Kill switch: BATCH_PIPELINE_RECOVERED_MERGE_RELEASE_ENABLED, default on; false restores the head wait and depth hold for recovered units. The registry row has a ramp block.

Why (5% run 18, T0 2026-10-20 13:51Z, ro-prod aggregates)

  • The wake did nothing: 46 of 54 post-recovery owner wakes (action=owner_chain outcome=summary) advanced 0 rows.
  • Why: a recovered unit re-enters the merge with ready_at set to its settle time. Behind an unready, earlier-captured head, which in run 18 was always head_state=leased (80 of 80 head_wait_bypass lines), 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.

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.

world release off release on
run 18 (leaks, worker without ready_at) 409 / 439 / 602 [65–73] 409 / 439 / 602 [0]
leaks, worker stamps ready_at 191 / 185 / 205 [50–68] 191 / 185 / 205 [0]
no leaks (Fix B live) 22 / 24 / 51 22 / 24 / 25

Verification

  • BACKEND_UNIT_TEST_FILE_LIST=<list> nice -n 19 bash backend/test.sh over the following, all passing:
    • test_batch_pipeline_recovered_release.py (10)
    • test_recovered_release_sim.py (3)
    • test_batch_pipeline_owner_chain_projection.py
    • test_batch_pipeline_merge_head_wait.py, test_batch_pipeline_merge_head_wait_sim.py
    • test_batch_pipeline_merge_fresh_first.py
    • test_batch_pipeline_serving.py
    • test_fresh_latency_sim.py
    • test_pipeline_sim_scenarios.py
  • scripts/check_feature_flag_registry.py: OK.
  • Layer: unit tests and the hermetic sim only. The live path has not been exercised.

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_release lines present, no new chain or privacy errors.

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

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

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]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 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-20T16:25:22.947607Z bcba5c8 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: 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".

Comment on lines +386 to +394
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))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +394 to +399
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()

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 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 👍 / 👎.

Git-on-my-level and others added 2 commits October 20, 2026 22:37
…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]>

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

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 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 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit f4dab79 into main Oct 20, 2026
57 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/batch-recovered-merge-release branch October 20, 2026 16:54
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