Repository navigation
3.x.x: let the async-promotion drill's new-tip shares wait for work at the payout revision the final block's confirmation set (#724) - #753
Conversation
…t the payout revision the final block's confirmation set (#724) The async-promotion drill's last check sends a share from each surviving session on work for the tip the final block moved to, and requires it accepted and credited once. It took the first job built on the new tip as that work. The final block moves the payout revision twice on the same parent, though. The frontend that first records the new tip bumps it (the chain observation in window.rs), and the block's landing bumps it again when it confirms the block (blocks.rs). Work a frontend publishes on the new tip between the two carries the first revision. Once the confirmation commits, the frontend refuses shares on that work, and on anything else it still publishes, as stale-job for the payout revision until it republishes on the confirmed one: the landing frontend at once, others at their next refresh (#752). A session whose first new-tip job came from that work submitted on it and was answered stale-job. Required CI answered this way twice (jobs 112241378522 and 113174599773). Each session now waits, under one 30 s deadline for the whole phase, until its latest job on the new tip comes from work at the ledger's payout revision. The drill reads the job's prepared record and the cluster's revision on the promoted primary, and reads past a job on superseded work to the session's next one through a new ShareClient::newer_work. A job without its issued row or prepared record is passed over the same way, as the final block's loop passes over a window the promoted ledger lacks (#619). A share refused stale-job because the revision moved past its work after that check is waited out too, after its ledger row is checked absent; any other refusal fails with the job's and the ledger's revisions. A session may meet work on one superseded revision, possibly on more than one job; a second is a revision move this drill never makes and fails. The first job on superseded work the drill meets gets one share, which must be refused stale-job and leave no ledger row, the original symptom kept as a check, and it joins the answers after the promotion. The jobs passed over and that share are reported in the drill's summary line, with their job ids. To prove it, two scratch delays, never committed, held the landing's confirmation 500 ms after its chain observation and each same-tip revision republication 1.5 s. The old drill then failed 6 of 6 runs, and 4 of 4 again after review, with CI's message, each share refused for its payout revision with the job's work on revision 2, the ledger on 3 and the published work on 2. The drill as amended passed 6 of 6 with the delays, every session passing over one job on revision 2 and the kept share refused stale-job without a row. Without them it passed 6 of 6 runs unpinned and 6 of 6 pinned to two CPUs, and with one injected revision move between a check and its share, 3 of 3. The first revision passed 8 of 8 with the delays and 10 of 10 each unpinned and pinned. 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: a6ff6d19f7
ℹ️ 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".
… in the drill's regression check (Codex on #753) Codex on #753: the drill's kept share on a superseded new-tip job had to be answered stale-job, but a correct server can also answer unknown-job. A session's job is retired when the server delivers the job that replaces it, whether or not the miner has read it, and it is pruned once retired past its retention (PRISM_STRATUM_SAME_TIP_JOB_RETENTION_SECONDS, 30 s by default) before a submission looks it up. A pruned job is resumed from its durable rows only while its frontend still publishes that payout revision, so a superseded one is answered unknown-job even though work_revision still finds its issued row and prepared record. A slow run can outlast the retention before it reads the session: the jobs are published before the phase's deadline starts, and the sessions are read one at a time. The kept share now passes with stale-job or unknown-job. Either way it must leave no ledger row, it joins the answers after the promotion, and the summary line names which answer came back. The retry after a refused share on work that was current at its check waits out unknown-job the same way, after the same no-row check, and lists such jobs as retired past retention. Any other answer still fails with the job's and the ledger's revisions. With the two scratch delays the drill passed 3 of 3, the kept share answered stale-job each time. Held 35 s more before that share, a further scratch, the share was answered unknown-job and accepted without a ledger row (1 of 1). Without the scratch the drill passed 3 of 3. 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: 5cddaac435
ℹ️ 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".
…se deadline (Codex on #753) Codex on #753: the new-tip phase's 30 s deadline bounded only its reads of new work. Its share submissions could each wait for an answer up to the client's 70 s limit, and its ledger reads had no bound, so one slow answer could run the phase far past its deadline or leave later miners nothing of it. Every step in the phase now runs under what is left of one deadline, through a small PhaseDeadline helper: the tip read, the revision reads, the share on current-revision work and its retries, the share on superseded work, the no-row checks, the wait for newer work and the credit count. An expiry fails the drill, naming the phase, the miner's session and job and how long the phase had run. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Set VERSION and [workspace.package].version to 3.0.0-rc.6: rc.5 plus #754 (the pool hashrate series bounds both of its ledger reads, the boundary buckets and the tail past the rollup watermark, at both ends, fixing a 3.x regression that timed it out on large ledgers), #750 (#748: a failed record of 2 is re-checked on a fresh connection when its own one was lost, and each attempt is bounded on the client's side), and #753, a test-only fix for #724. Both Cargo.lock files move only their workspace-member entries. doc/release-notes-3.0.0-rc.6.md covers: - the changes, with #754's figures from its pull request (19 to 40 s and a 504 on a 66M-share ledger before, and 17 to 27 s with only the boundary fixed; 1 to 17 ms on a 6M-share copy after, under every plan mode and random_page_cost tried, with its output matching rc.5's; and on a production-sized ledger, 9 to 23 ms for the pool and 2 to 15 ms for miners in 20 of 20 runs, against rc.5's 15.8 to 25.2 s, with identical output), #750's lost connections, fresh read, client-side deadlines and two new stops, and #753's wait for current work; - upgrading: rc.6 adds no migration, capability, setting or script, so an upgrade from rc.5 and a rollback to it replace the binary only, at fence 2 too, and a database that rc.5's migrate migrated is served by rc.6 unchanged, which a cutover that pinned rc.5 can rely on. An upgrade from rc.4 or earlier is as in rc.5's notes, which the section links: migrate for 026, fence 2 and the deferred backfill, #738's snapshot rule and fatal-state clear --timeout-seconds; - the same evidence set as rc.5's, with the pair's serving evidence carried; - the known issues: rc.5's, with #748 fixed and #724's drill race and new-tip shares fixed on the test side (#747, #753), plus #752 after the cutover, #738's fix now planned after the cutover, and #739 not in this candidate. The development-line notes name 3.0.0-rc.6, and they and the 3.0.0 notes link all six candidates' notes. docs/prism-rust-migration.md names rc.5 where it said "this release" of serving at fence 2 and finishing the backfill. That is in three places: that every build before rc.5 refuses fence 2, that the starts of rc.5 and later accept it, and that only rc.5 and later finish a pending backfill. In this candidate's tree "this release" would have excluded rc.5, which does both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Part of #724: this fixes its original symptom in
pg_failover_tests::async_live_miners::async_promotion_with_live_miners_accounts_for_every_share_and_lands_a_block,miner N's share on work for the new tip was answered stale-job. It changes the test only. The server behaviour it waits out is filed as #752.Required CI hit it in jobs 112241378522 (miner 0) and 113174599773 (miner 1, #750's head).
The drill's last check took the first job built on the new tip as current work. The final block moves the payout revision twice on that tip, and new-tip work published between the two moves is superseded at once. The drill now waits until each session's job on the new tip comes from work at the ledger's revision. It also keeps the original symptom as a check: a share on superseded work must be refused and never credited.
A scratch delay on the server side reproduces CI's message every time. The server's refusal names the cause: the job's work on revision 2, the ledger on 3. The drill as amended passes every run with that delay (Proof, below).
Mechanism
work_on(tip), which returns at the first job whose parent is the new tip, then submitted a share on it and requiredaccepted(tests/support/live_pg_async_live_miners.rs, the new-tip loop).ledger/window.rs~557). That frontend is either a refresh woken bywaitfornewblock, or the landing's ownobserve_candidate(coordinator.rs~2038-2052).chain_state='confirmed'(ledger/blocks.rs~322-334).submit_sharerefuses a plain share whose work revision, or whose frontend's published revision, differs from the durable one:StaleJobCause::PayoutRevision(coordinator/miner_submit.rs~486-497). That includes a share on the frontend's own still-published work.share_leasecovers only a tip change (coordinator/tip_observation.rs~540-553).coordinator.rs~3021). Other frontends learn at their next refresh tick,PRISM_BLOCKPOLL_SECONDS(0.2 s in the drill; 2 s by default,config.rs~636).Fix
Waiting for current work:
work_on(tip), each session reads its job's prepared record and the cluster's payout revision on the promoted primary (work_revision). It compares the prepared record's revision,context.prepared.snapshot.payout_revision, which is whatsubmit_sharechecks. An issued row stores the revision current at issuance, which can differ under a share lease.ShareClient::newer_work) and checks again. If an answer already brought the next job, it doesn't wait.Submitting:
stale-jobbecause the revision moved past its work after the check, the drill checks that the share left no ledger row, records it among the post-promotion answers, and waits for newer work.Bounds and checks:
stale-joband leave no row inqbit_share_ledger. It joinsafter, the drill's book of answers after the promotion.The accounting of the drill's earlier phases is untouched. The only shares this phase adds are the refused ones above, each checked against the ledger.
Proof
All runs used one test with
--exact --test-threads=1, a fresh database each, PostgreSQL 16.10, pinned qbitd 1.0.0, through the host's heavy-job guard. The scratch was never committed:observe_candidateandfinish_candidate_counted_at_revision(coordinator.rs~3013);RefreshTrigger::Revision) held 1.5 s before its reservation (coordinator.rs~1800);PayoutRevisionrefusal, logging the job's, durable and published revisions.payout_revision, job's work 2, ledger 3, published 2stale-job, no ledger rowtaskset -c 0-1stale-job, no row, then accepted on the next jobGates
cargo fmt --all --check: clean.cargo clippy --locked -p qbit-prism-server --all-targets -- -D warnings: clean.cargo test --locked -p qbit-prism-server --test live_regtest -- --liststill lists the test under the same name (97 tests), astest/prism-gated-tests.txtpins it.Review
A
/code-review highof the first revision confirmed the ordering, the comparison, the bound and the accounting, and raised 9 minor items. All 9 are fixed:stale-jobbecause the revision moved past its work after the check is waited out within the deadline. Its ledger row is checked absent. Any other refusal fails with the work and ledger revisions before and after the share. This was exercised with an injected move (3 of 3).stale-job, no ledger row, inafter. In ordinary runs no superseded job is met, so the check runs only when the race does. With the delays it runs every time.newer_work's inner error carries the miner, the job and its revisions.left()closure.superseded(andunrecorded) entries, so the summary joins toqbit_prism_jobsand the logs.Not in this PR
backend-rpc-unavailableanswer to a lost acknowledged share's replay (3.x.x: a share under a tip-change lease is refused 'commit gate closed' when the authority try_read meets a writer, which can drop a valid share's credit and fires PrismShareAppendFailures #716's commit-gate class).🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.