Repository navigation
3.x.x: retry a post-offer write that lost a payout-revision race in place, instead of an ALERT and reconciliation (#630) - #798
Merged
Conversation
…lace, instead of an ALERT and reconciliation (#630) Each post-offer write (the landing, the finish as submitted, the orphan settlement) is fenced on the payout revision its own candidate observation returned. When a sibling frontend recorded a tip or confirmed the block between that observation and the write, require_revision refused the write with an untyped error. settle_offered_candidate then settled the row in reconciliation and logged "ALERT: offered candidate could not be processed" (or "could not land"), about once in three landings on the 400k two-frontend soak, although nothing had failed. #696 documented the line as benign. - require_revision returns a typed ObservedRevisionChanged (same message), raised before the refused transaction's first write. - One RevisionRetry per post-offer phase: on that error alone the caller observes again and writes again at the new revision, at most 3 times per phase. No retry starts 60 s or more after the phase's first lost race (not its start: the rebuild before the first write can take most of a minute under the load that makes the race likely), and a started write is never cancelled, so its outcome stays known. The landing is retried from the same rebuilt parts. A finish or orphan settlement is retried from a fresh observation and never repeats a committed landing. A confirmation a sibling already committed is not applied again. - Each retry logs an INFO line ("post-offer write lost a payout revision race; observing again and writing at the new revision"). Every other error, and a race that outlasts the budget, keeps today's ALERT and reconciliation; the spent budget is named in the reason. - candidates recover gets the landing retry through land_offered; its finish is unchanged. - docs/prism-ledger-ops.md: the #630 runbook section now describes the retry, the INFO line, and when the ALERT can still appear. Tests: tests/post_offer_revision_race.rs (PostgreSQL-gated, listed in test/prism-gated-tests.txt) points the coordinator at a front for the scripted node. The front runs a scripted step on the getblockhash that every candidate observation makes after reading the revision and before the write, so a revision move lands strictly between the two. It covers: - a sibling confirmation racing the finish, after the landing committed; - a bump racing the landing; - a race on every write that spends the budget; - a node failure after the landing; - an orphan settlement whose race is retried and whose second, genuine refusal (the block is confirmed) keeps the ALERT. Raced cases equal a no-race control's balances, payout entries, carry rows, blocks and credits, with one submitblock and one confirmation. On the base, the four race tests fail and the node-failure test passes. Lib unit tests cover the error classification and the deadline running from the first lost race. 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. |
…nced commit, with a budget per write phase
Follow-ups from the pre-PR review of the post-offer revision-race retry.
- Effective landing retry. The landing is split into
Ledger::verify_landing (the whole-window verification, the coinbase check,
the stored body and the durable-range proof, done once) and
Ledger::land_verified_at_revision (the fenced transaction alone).
land_offered verifies first, then observes and commits. Only the commit is
retried, each time right after a fresh observation, so the revision is read
just before the transaction instead of before seconds of verification. The
guarantees are unchanged: require_revision runs before the transaction's
first write, and an audit that landed meanwhile is compared by digest.
- A landing retry lands only a block its fresh observation still shows
active. If the block left the active chain, nothing lands and the row is
reconciled as a block not active after its offer (WARN, no ALERT).
candidates recover stops with NotActive.
- One budget per write phase. A generic through_revision_races driver owns
a RevisionRetry for the landing and another for the settlement (finish or
orphan), so the landing's races no longer spend the settlement's retries or
start its clock.
- Jittered backoff between retries: about 50 ms, doubling per retry, ±50%,
capped by the deadline.
- candidates recover retries its finish through the same driver, and
counts qbit_prism_blocks_total by first_confirmation instead of
unconditionally.
- The driver writes nothing itself; every side effect (the blocks counter,
the wake, the orphan metric and its WARN) is applied straight-line after the
committed write returns.
- New counter qbit_prism_post_offer_revision_races_total{phase,outcome}
(landing|settlement, retried|spent), with registry, zero-registration,
metadata, the generated inventory and the observability census and
cardinality pins.
- A spent budget names its actual reason: all 3 retries used, or the 60 s
deadline from the first lost race passed after N retries.
- Runbook (#630 section) updated for all of the above.
Tests:
- tests/post_offer_revision_race.rs gains three PostgreSQL-gated tests:
- a landing retry after a reorg lands nothing;
- the landing and the settlement each have their own budget;
- candidates recover retries its finish and counts only a first
confirmation.
- Each fails on ac15308's coordinator, and the counting half fails on a
mutant that counts unconditionally.
- New unit tests drive the phase driver under paused time. The deadline runs
from the first lost race (they fail on the M4b-style mutant that seeds it
when the phase begins), only a lost race is retried, the backoff stays
within bounds, and the counter counts.
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: b018925873
ℹ️ 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".
…etry starts at or past it (Codex P2 on #798) RevisionRetry::again decided to retry before its backoff. The backoff is clipped to the time left before the deadline, and the runtime can wake late, so a race lost just before the 60 s deadline, with retries left, slept to the deadline or past it and then still started another full observation and write, contrary to the documented limit. again() now sleeps first and decides afterwards. Once the deadline has passed, it returns the spent-budget refusal that names the deadline as the reason. The retry count, the INFO line and the retried counter are recorded only when a retry really starts; the INFO line's backoff_ms is the time actually waited. New paused-time unit test coordinator::revision_retry_tests::a_race_lost_just_before_the_deadline_starts_no_retry. A refusal 1 ms before the deadline, with retries left, produces no further attempt. The test fails (3 attempts) when the deadline is checked against the time before the sleep. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #630. When the payout revision moved between the post-offer observation and the write,
settle_offered_candidatesent the row to reconciliation with "ALERT: offered candidate could not be processed". That happened about once every 3 landings on the 400k two-frontend soak. #696 only documented the lines as benign.What changes
require_revisionreturns a typedObservedRevisionChanged.docs/prism-ledger-ops.mdis rewritten to match.Tests
post_offer_revision_race: 5 tests. The 4 race tests fail on the base, and the node-failure test passes.offer_lifecycle26/26, libcoordinator357/0 and libledger::candidates22/0.ledger_postgres253/253,ledger_single_execution,lost_race_pin,migration_rollbackandoffer_latencypass.Follow-up round (b018925)
Ledger::verify_landing, which does the verification, coinbase check and durable-range proof once, andland_verified_at_revision. Only the fenced transaction is retried, right after a fresh observation, so a retry has only a narrow race window.require_revisionstill runs before the first write.recoverstops withNotActive.candidates recoverretries its finish too, and counts blocks byfirst_confirmation.qbit_prism_post_offer_revision_races_total{phase,outcome}, with the regenerated docs. The spent message names its real reason.post_offer_revision_race8/8,revision_retry_tests3/3,offer_lifecycle26/26,ledger_single_execution22/22,lost_race_pin8/8, observability 17/17. Each new test fails on ac15308.🤖 Generated with Claude Code