Repository navigation
3.x.x: answer a share whose commit gate closed for unavailable authority as backend-rpc-unavailable, not ledger-confirmation-failed (#716) - #718
Merged
RobertClarke merged 2 commits intoOct 6, 2026
Conversation
…ity as backend-rpc-unavailable, not ledger-confirmation-failed (#716) A share admitted under a published-work lease checks that authority again just before COMMIT, with a non-blocking try_read. During a tip change the tip poll, a fee or readiness write, or the publication itself can hold or wait for one of those locks. The gate then closes as AuthorityUnavailable, and the share was answered ledger-confirmation-failed, "share was not committed because its commit gate closed". Nothing is written, so the ledger is fine. But that reason feeds PrismShareAppendFailures, so the alert fired at tip changes under load: 4 refusals in N2's D1 run at rc.1. Now the closure that won the gate decides the answer: - A proven stale lease (StaleAuthority) stays stale-job. - AuthorityUnavailable answers backend-rpc-unavailable, "current chain state is unavailable", the answer admission gives when it can't prove readiness or the lease. It is still never credited, and not stale-job, since a failed try_read proves nothing about the work. - A deadline closure and a refusal with no recorded closure stay ledger-confirmation-failed. The INFO "share commit gate refused before COMMIT" now carries a closure field and is logged where the closure is known. Admission's identical refusals share one constructor, chain_state_unavailable(). The credit-preserving fix, which retries instead of refusing, stays open in #716. 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: 37df63bac6
ℹ️ 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".
…, and name the database when the refresh failed on it (#716) A lease fence can close the commit gate at the pre-COMMIT hook while the append's ROLLBACK is still in flight at the acknowledgement deadline. gate.close() also reports such an already-closed gate, so the deadline path aborted the append and answered its own ledger-confirmation-failed. That turned a proven stale lease, or unavailable authority, back into the failure this change stops feeding PrismShareAppendFailures. The deadline path now asks the gate which closure won it. Both paths share closed_gate_outcome(), which logs the INFO line with its closure field. AuthorityUnavailable is answered as admission answers readiness it cannot prove: stale_readiness_reason() picks backend-database-unavailable when the latest refresh failed on the ledger database, or the refresh in flight is still blocked on it (#581, #655), and backend-rpc-unavailable otherwise. It uses the readiness flag admission already read, because the readiness lock's contention may be what closed the gate. The admission sites keep their own literals; the shared constructor is gone. Tests: - The closure test adds the database case and checks the INFO line's closure label. - A new test holds the refused append's rollback past the deadline. Without this fix it fails with "share was not confirmed by the database". - The memory ledger's unspecified refusal now keeps the duplicate check, as the production hook does. The docs describe what the authority-unavailable closure covers beyond lock contention. Co-Authored-By: Claude Opus 5.5 <[email protected]>
RobertClarke
added a commit
that referenced
this pull request
Oct 6, 2026
…-rpc-unavailable #718 (caa4e84) landed before the rc.2 tag. Per the coordinator, rc.2 includes it, with no revert, and #717 is rebased onto it. The notes now: - name the change: a share refused at the commit gate because chain-state authority was briefly unavailable at a tip change answers backend-rpc-unavailable ("current chain state is unavailable"), or backend-database-unavailable, instead of ledger-confirmation-failed. So PrismShareAppendFailures no longer fires for it. The share is still never credited; the credit-preserving retry is #716's follow-up; - give the runtime changes since rc.1 as migration 025 plus #718's answer in coordinator/miner_submit.rs; - move #716 from the open issues to the partly fixed ones. Co-Authored-By: Claude Opus 5.5 <[email protected]>
RobertClarke
added a commit
that referenced
this pull request
Oct 6, 2026
Set VERSION and [workspace.package].version to 3.0.0-rc.2: rc.1 plus migration 025 (#708, #710), #718's commit-gate answer for #716, and the legacy-audit-body sidecar tool (#715). Both Cargo.lock files move only their workspace-member entries. doc/release-notes-3.0.0-rc.2.md covers: - the changes since rc.1 (U3's lines, and #716 fix A in the coordinator's words); - upgrading from 2.0.x (the sidecar tool and FETCH_COUNT) and from rc.1 (migrate before any rc.2 frontend starts); - the lean verification, since the runtime changes are 025 and #718; - the known issues, including #711, #712, #713 and #704. The development-line notes name 3.0.0-rc.2 as the tree's identity, they and the 3.0.0 notes link both candidates' notes, and a doc example's tag reads v3.0.0-rc.1. L3 run 37444397320 (l3-full) measured this tree. 32 of 33 runs passed. throughput-400k-window-2fe-async-3-blocks-r2 refused one valid share at the commit gate (#716's open part, answered backend-rpc-unavailable), and the coordinator carried that verdict as a named exception. Co-Authored-By: Claude Opus 5.5 <[email protected]>
RobertClarke
added a commit
that referenced
this pull request
Oct 6, 2026
…, and what each pair figure measured From the review of #722, with the figures confirmed by the coordinator: - #716 (open part) gives its three measured rates: 4 in about 149k shares in N2's rc.1 D1 sustained run on the pair, 1 in about 121k in the peak run on #719's build, and 1 in about 150k in rc.2's L3. - #712 stays in the known issues. #721's parallel export shortens the export, but the source export is still on the critical path and both exports sit inside the cutover outage. #721's \gset move in the serial SQL is mentioned. - #711 is improved by fix B and stays open for fix A, with the ceiling still flagged under 788. - Each pair figure says what it measured: - rc.1's 1,479 ms is on the same shape, and an earlier under-offered run measured 1,116 ms; - the 1.473 ms hold is order_lock_hold_seconds{holder="append"} on the rc.1 runtime; - the 750/s ceiling is with the load balancer preferring the primary's frontend; - the failover drill run is described. - The measured build is rc.3 without #718's answer mapping, and the 2.0.x upgrade points to the parallel export. Co-Authored-By: Claude Opus 5.5 <[email protected]>
11 tasks
kiwidream
added a commit
that referenced
this pull request
Oct 27, 2026
… share keeps its credit (#716) (#788) A share admitted under a tip-change lease checks its chain authority at the pre-COMMIT hook, under ORDER_LOCK, with non-blocking try_reads. While the tip poll, a fee or readiness write, or the publication holds or is queued for one of the three authority locks, the read fails. Since #718 the gate then closed as AuthorityUnavailable and the share was answered backend-rpc-unavailable: nothing was written, so a valid share lost its credit. The L3 preset throughput-400k-window-2fe-async-3-blocks fails on exactly this, `steady_state: valid shares refused` 1-3 per run (#779). This is #716's fix B. Contention proves nothing about the lease, so it no longer closes the gate: - LeaseCommitFence reports a failed try_read as Contended, apart from Unavailable (readiness or tip authority lapsed) and Stale. - CommitGate gets a Contended state. A contended hook moves the gate there by compare-and-swap from Open and refuses; the append rolls back as before, releasing ORDER_LOCK. - CommitGate::retry_after_contention waits for the authority outside ORDER_LOCK and any transaction (the ordered AuthorityView read that admission already uses), checks the lease against it as the hook does, and drops the guards. A lease that still holds reopens the gate (Contended to Open) for another attempt; a revoked one closes it with its own answer (stale-job, or current chain state is unavailable). - close_for closes a contended gate too. The deadline, or a cancellation, that finds the append still waiting out contention closes it as the new AuthorityContended: answered as authority the gate cannot prove, and logged closure="authority-contended", because the authority held the share back, not the ledger. - persist_share_pass's append task loops on that. Only a fenced append can be retried, and it never carries a candidate, so the retry copies only the share. The acknowledgement and credit invariants hold because COMMIT is still sent only after the one Open-to-Committing transition, and every close leaves Open or Contended by compare-and-swap, so no attempt can commit once the deadline closed the gate. A retried attempt is a fresh transaction after a definite rollback, and the immutable share_id row still deduplicates. The authority guards are never held across database I/O, and the deadline bounds the loop. Each retry logs INFO "share commit gate waited out contention for its authority; appending again" with share_id and waited_ms. docs/prism-rejections.md, the rejections_total metadata and the generated inventory describe the new behaviour. Tests: the old contention test held a writer's guard across the hook and expected a refusal; it is replaced by tests that the share waits and is credited for each of the three locks, that a publication or readiness epoch change during the wait keeps that change's answer, that the deadline during the wait is answered as contended authority and nothing commits after it, and that unknown readiness is still refused without a retry. A gate unit test covers the Contended transitions, the closure table gains authority-contended, and the PostgreSQL hook test now proves through real SQL rollbacks that a contended gate reopens and commits the same share after the wait. The three contention tests fail on the previous code. Refs #716, #779. 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 #716
Why. A share admitted under a published-work lease checks that authority again just before COMMIT, while the append holds ORDER_LOCK. The check uses non-blocking
try_reads on the frontend's publication authority. During a tip change, the tip poll, a fee or readiness write, or the publication itself can hold or queue for those locks, and then the gate closes asAuthorityUnavailable. The same closure covers readiness or a tip observation that lapsed or changed. Until now that closure was answeredledger-confirmation-failed, "share was not committed because its commit gate closed".Nothing is written, so the ledger is fine. But
ledger-confirmation-failedis whatPrismShareAppendFailurescounts, so the alert fired at tip changes under load. N2's D1 run on the pair at rc.1 saw 4 such refusals in 500/s for 300 s across 7 tip changes, and the alert fired.What changes for miners. The closure that won the gate decides the answer:
StaleAuthority, where the lease expired or its publication was replaced, staysstale-job.AuthorityUnavailableis answered as admission answers readiness it cannot prove, with message "current chain state is unavailable".backend-rpc-unavailable, orbackend-database-unavailablewhen the latest template refresh failed on the ledger database or the refresh in flight is still blocked on it. That isstale_readiness_reason(), as admission's aged-readiness answer uses (3.x.x: database clock steps stretch outbox retries and claim leases; a PostgreSQL outage holds only one alert rule #581, 3.x.x: two database-stall paths still label their refusals backend-rpc-unavailable (follow-up to #581) #655).stale-job, because a failedtry_readproves nothing about whether the work went stale.ledger-confirmation-failed. In production the deadline answers before this classification, with "share was not confirmed by the database", which is also unchanged.The numeric code stays 20, so Stratum clients see only the reason ID and message change.
The deadline race (Codex's P2):
gate.close()also reports an already-closed gate, so the deadline path used to abort the append and answer its own ledger failure. That applied to a proven stale lease too.closed_gate_outcome().Metrics and alerts:
PrismShareAppendFailuresmatchesreason_id=~"ledger-confirmation-failed|ledger-outcome-unknown"(docs/prism-native-alert-rules.json), so this case no longer fires it.qbit_prism_rejections_total{reason_id="backend-rpc-unavailable"}, orbackend-database-unavailableas above. Only the reject-ratio rules watch those reasons, at 5% of decisions; a handful of refusals per tip change doesn't come close.share commit gate refused before COMMITnow has aclosurefield, and is logged where the closure is known.authority-unavailablewithin seconds of a tip change is the contention case. Away from tip changes it is a readiness loss.share persistence failedis still the real ledger failure.docs/prism-rejections.mddescribes the cases under "Commit-gate refusals". The reason table and the metric inventory list this new source of both reasons.What stays strict:
ledger-confirmation-failed.candidate_currentandblock_captureboth require!share_lease. So no found block takes this path.The load harness needs no change.
qbit_prism_load::classifyalready counts both reasons as backend refusals, as it doesledger-confirmation-failed, and the live session-load test already expects them.Tests:
commit_reconcile_each_gate_closure_keeps_its_own_answerdrives each closure throughsubmitwith the memory ledger.closurelabel.commit_reconcile_a_fence_closure_keeps_its_answer_when_the_rollback_outlasts_the_deadlineholds the refused append's rollback past a 300 ms deadline. Both fence closures keep their answers, and the append is aborted. Against the old deadline path it fails with "share was not confirmed by the database".Three
authority_leasetests pinned the old answer for this closure: a changed readiness epoch, an aged tip observation, and the lock-contention and unknown-readiness matrix. They now expectbackend-rpc-unavailable. The matrix's held readiness write lock is what showed the answer must not re-read readiness.candidate_window_qualification's phase-B allowance after the tip move also accepts the gate's new answer. By design that answer is admission's too, so the comment notes that the wire can't tell the two apart there.Local runs, without a database:
coordinator::lib tests: 341 of 341 passed;-D warnings,cargo fmt --checkandscripts/generate_prism_metrics.py --checkare clean.CI runs the full gated suite.
Runtime code changes only in
coordinator/miner_submit.rs, plus a test-only gate hook insubmit_ledger.rs. It's an rc.3 candidate alongside #711's fix (B), and is not to be merged without the coordinator's go.🤖 Generated with Claude Code