Skip to content

3.x.x: document the post-offer payout-revision race's ALERT lines as benign, and when to act on them (#630) - #696

Merged
RobertClarke merged 2 commits into
3.x.xfrom
RobertClarke/630-runbook-note
Oct 6, 2026
Merged

RobertClarke merged 2 commits into
3.x.xfrom
RobertClarke/630-runbook-note

Conversation

@RobertClarke

@RobertClarke RobertClarke commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

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 typed require_revision error 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:

  • the two lines: ALERT: offered candidate could not land and … could not be processed. When the reason ends payout revision changed while observing chain state, either one is a lost race;
  • what happened: each post-offer write is fenced on the revision its claim observed: the landing (land_candidate_at_revision), the finish as submitted (finish_candidate_counted_at_revision) and the settlement as orphaned (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;
  • why it is benign: the refused write changed nothing. The row's next claim, at its next_attempt (min(3600, 10 × attempt_count) s), observes again, lands if needed, and settles submitted or orphaned. The confirmation and deferred-share credit commit once, whichever side commits them first (reconcile_blocks_in, append_in's idempotent duplicate);
  • how it counts: while it lasts, a lost landing counts as landing-failed, a lost finish as pending only, and a recovered reservation as unacknowledged. No candidate alert fires before a row has been unfinished for at least 3 minutes;
  • when to act: only if candidates list still shows the block after a few retries, or its last_error names another reason. Never by abandoning it: abandon refuses 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_offered and process_candidate_inner in coordinator.rs;
  • require_revision in ledger/connect.rs;
  • the four fenced writes and reconcile_blocks_in in ledger/blocks.rs;
  • observe_chain_view's tip bump in ledger/window.rs;
  • the backoff and claim increments in ledger/candidates.rs;
  • the census filters in metrics/collectors.rs;
  • the thresholds in docs/prism-native-alert-rules.json.

No code changes. scripts/check_prism_settings.py and scripts/check_deleted_test_map.py pass, and no existing anchor in the doc changed.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

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

chatgpt-codex-connector Bot commented Oct 6, 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-06T02:48:53.513751Z c4956e3 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: 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".

Comment thread docs/prism-ledger-ops.md Resolved
…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]>
@RobertClarke
RobertClarke merged commit 94d55c2 into 3.x.x Oct 6, 2026
34 checks passed
@RobertClarke
RobertClarke deleted the RobertClarke/630-runbook-note branch October 6, 2026 03:05
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]>
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