Repository navigation
3.x.x: document the post-offer payout-revision race's ALERT lines as benign, and when to act on them (#630) - #696
Merged
Conversation
…benign, and when to act on them (#630) Every post-offer write of a claimed block candidate is fenced on the payout revision its claim observed: the landing, the finish as submitted and the settlement as orphaned. Any frontend moves that revision when it records a new tip or confirms, deactivates or matures a block. That happens right after an own block is accepted, when a refresh records the block as the new tip and confirms it once its audit has landed. A write that loses that race is refused. The frontend logs "ALERT: offered candidate could not land" or "... could not be processed", with a reason ending "payout revision changed while observing chain state", and the row settles in reconciliation. Its next claim observes again and finishes it, and the confirmation and the deferred-share credit commit once, whichever side commits them first. The ledger-ops runbook now explains what those lines mean and why they are benign, how they count in the candidate census and alerts, and when to act on them. The rule: only if the block is still listed after a few retries or its reason changes, and never by abandoning it. The product fix, retrying the write in place, stays open in #630. 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: 4fee0e98ed
ℹ️ 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".
…ocks, not old or many-attempt rows (#630) The candidate alerts measure a row's age from when it was created or reserved, not from the race, and a row's retry waits 10 x attempt_count seconds. So an old recovered reservation, or a row that met the race after earlier reconciliation attempts, can fire an alert even when the race clears on its next retry. Codex review on #696. Co-Authored-By: Claude Opus 5.5 <[email protected]>
kiwidream
added a commit
that referenced
this pull request
Oct 28, 2026
…lace, instead of an ALERT and reconciliation (#630) (#798) * 3.x.x: retry a post-offer write that lost a payout-revision race in place, 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]> * 3.x.x: #630 pre-PR fixes: verify a landing once and retry only its fenced 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]> * 3.x.x: #630 check the retry deadline again after the backoff, so no retry 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]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Refs #630. This is the docs-only part: an operator runbook note in
docs/prism-ledger-ops.md, "A lost revision race after the offer (#630)", under "Durable block candidates". The product fix stays deferred, and #630 stays open for it: a typedrequire_revisionerror plus a bounded retry of the write, so a lost race stops logging an ALERT.Why now. The PRISM 3 pair rehearsal and cutover will see these lines on a share of own-block landings, at a 400k window with two frontends. An operator who reads them as incidents could take the wrong action on an accepted block. The note covers:
ALERT: offered candidate could not landand… could not be processed. When the reason endspayout revision changed while observing chain state, either one is a lost race;land_candidate_at_revision), the finish assubmitted(finish_candidate_counted_at_revision) and the settlement asorphaned(orphan_candidate_at_revision). The revision moves with every new tip, block confirmation, deactivation or maturity, policy transition and fatal-state clear. Right after an own block is accepted, a refresh on either frontend records it as the tip and, once its audit has landed, confirms it;next_attempt(min(3600, 10 × attempt_count)s), observes again, lands if needed, and settlessubmittedororphaned. The confirmation and deferred-share credit commit once, whichever side commits them first (reconcile_blocks_in,append_in's idempotent duplicate);candidates liststill shows the block after a few retries, or itslast_errornames another reason. Never by abandoning it:abandonrefuses an offered row, with exit 3.The note also fixes "Candidate commands"' opening line ("the rows above"), which would otherwise point at this note instead of the state table.
Checked against the code at
c95febb3:settle_offered_candidate,settle_offered_inner,land_offeredandprocess_candidate_innerincoordinator.rs;require_revisioninledger/connect.rs;reconcile_blocks_ininledger/blocks.rs;observe_chain_view's tip bump inledger/window.rs;ledger/candidates.rs;metrics/collectors.rs;docs/prism-native-alert-rules.json.No code changes.
scripts/check_prism_settings.pyandscripts/check_deleted_test_map.pypass, and no existing anchor in the doc changed.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.