Repository navigation
Conversation
Codex Review Summary: ✅ CompletedThis 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. |
…ilover and a mixed 3.1.1/3.1.2 cluster doc/release-notes-3.1.2.md describes, in 3.1.1's structure, every pull request merged into 3.x.x since v3.1.1 (d0c649b..af44806): what changed, what an operator must do and what they may now observe. It says that an .env copied from 3.1.1's .env.example keeps the authorize budget off and Qbit Core at v1.0.0, that the listener-down rule must follow the binaries both ways, and what a 3.1.1 frontend, dual-writer node or verifier does with work paid to the pool-fee address (#822). It ends with the pull requests still in review, for the release coordinator to replace. The runbooks follow: - the HA failover's step 5 restarts both frontends after moving the writer endpoint, unless the move resets every established connection; ledger operations and the migration guide point to it; - ledger operations gets the #822 mixed-version runbook, with pointers from PRISM.md and the pool-fee procedure; - the configuration guide says an explicit =0 in .env wins over the new authorize default; - the alert migration says to roll the listener rule back before the binaries, and adopts #844's rule. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ram block, three .env lines, the listener rule alone follows rollbacks From the local review: - any frontend's submit loop claims whichever candidate row is due, so a 3.1.1 frontend can take a 3.1.2 frontend's fee-program block with no frontend failing (notes and ledger operations); - the pin is two lines, so an old .env keeps three; only the listener rule must follow the binaries both ways; - the tag goes on the promotion into main; If-None-Match: * still answers 304; 924.6 s is the kernel's lower bound, not the expected wait; - the identity cache's eviction order is the code's; - the failover restart uses the deployment's own Compose files and project, and is checked; - the in-review list names the accept() error fix only (ntime moved to #895). Co-Authored-By: Claude Opus 5.5 <[email protected]>
kiwidream
force-pushed
the
orca/3.1.2-notes-and-runbooks
branch
from
November 18, 2026 15:24
4be8587 to
b626def
Compare
djh58
added a commit
that referenced
this pull request
Nov 23, 2026
): fixes the coordinator CPU spin Backports [transact-rs/sqlx#4289](transact-rs/sqlx#4289), "fix(pool): prevent num_idle underflow that wedges maintenance in a CPU spin" (merge commit `5d3787ef9d69947065085f46b58767a50b3d8e25`, merged 2026-09-10, first released in sqlx 0.9.1 on 2026-11-18), into the sqlx-core 0.8.6 that #794 vendored. It is in neither 0.8.6 nor 0.9.0. ## Observed in production A production PRISM v3.1.1 coordinator stalled repeatedly, for minutes to hours at a time. One tokio worker thread sits at 100% user CPU and never enters a syscall, while every other thread waits. A read-only `perf` sample put 100% of that thread's samples in: - `sqlx_core::pool::inner::spawn_maintenance_tasks::{closure#1}` - `ArrayQueue<Idle<Postgres>>::pop` - `tokio::sync::batch_semaphore::Semaphore::add_permits_locked` That is the pool's maintenance sweep, `for _ in 0..pool.num_idle()`, running on an empty idle queue with `num_idle` wrapped to about `usize::MAX`. 0.8.6's `release()` pushes a connection onto the idle queue and releases its permit before it adds one to `num_idle`, while `pop_idle()` pops and then subtracts one. An acquire that lands between the two subtracts first, and with the count at 0 it wraps until the add lands. The maintenance task reads the count once as its loop bound. With the queue empty the loop body never awaits, so a task that read the wrapped count keeps its worker for good. The stalls recur on a 30-minute rhythm, because every connection reopens together after each stall and they all reach the 30-minute `max_lifetime` together. ## The change `vendor/sqlx-core/src/pool/inner.rs` takes upstream's diff: - `release()` adds to `num_idle` before it pushes the connection; - `pop_idle()` subtracts saturating at 0; - the maintenance sweep makes at most `min(num_idle(), max_connections)` checks. Those three code changes are upstream's, line for line (the added and removed lines of the hunks diff empty against upstream's commit). Nothing else in the vendored crate's code changes. Upstream's stress test, `underflow_tests`, comes with them. It needed two adaptations to build and run on 0.8.6, both recorded in `vendor/sqlx-core/README.md`: - its stub backend takes 0.8.6's `AnyConnectionBackend` signatures (`&str` and `Cow<'static, str>` where 0.9 has `SqlStr`, and `describe` without the `offline` gate); - its pool sets neither `max_lifetime` nor `idle_timeout`, so that it spawns no maintenance task and needs no runtime. `vendor/sqlx-core/README.md` gains the #4289 entry in the style of #4251's and #3861's. ## Test evidence Upstream's test, run from a copy of the vendored crate with `cargo test --lib --features any,_rt-tokio underflow` (12 threads, 200,000 acquire and release cycles each, on a pool of 3): | Pool code | Debug | Release | | --- | --- | --- | | 0.8.6 as vendored before this change | 5 of 5 fail: `saw 18446744073709551615, max 3` | 3 of 3 fail, same message | | with this change | 5 of 5 pass | 3 of 3 pass | Also run locally: - `cargo check --lib --features _rt-tokio,_tls-rustls-ring-webpki,json,chrono,migrate` on the patched crate: clean, with only the three warnings upstream ships; - `python3 scripts/check_vendored_sqlx_core.py`: both lock files use `vendor/sqlx-core` 0.8.6, 0 advisories; - `python3 -m unittest tests.test_check_vendored_sqlx_core`: 11 tests pass. Not run locally: the workspace build and test suites. The host had 1.6 GB of disk free, so CI is the first full build of this. ## What this does not cover - **CI does not run upstream's test.** It is a unit test inside sqlx-core, and Cargo tests only workspace members. The README says how to run it. Nothing in CI fails if these hunks are lost; a regression test through the public pool API in `crates/qbit-prism-server/tests/`, as #4251 and #3861 have, would close that. - **The sweep cap has no test of its own**, upstream's included: with the reordering in place the count cannot wrap, so the cap is never reached. - **No version bump, tag or release.** `VERSION` stays 3.1.1. - **Release notes.** The pending 3.1.2 notes in #897 need an entry for this fix; this PR adds none, as `main` has no unreleased notes file. - **3.x.x.** The fix reaches 3.x.x by merging `main` into it after this lands. There, #836's source check requires the change recorded as a patch in `vendor/sqlx-core.patches/`, and the README has diverged, so that merge needs both resolved. Refs #794. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Squashed commits: 192603d main: backport sqlx's pool num_idle underflow fix (transact-rs/sqlx#4289): fixes the coordinator CPU spin 6db3769 vendor/sqlx-core/README.md: say what the #4289 backport is for without deployment details Co-Authored-By: Claude Fable 5.2 <[email protected]> Squashed-from: 6db3769
djh58
added a commit
that referenced
this pull request
Nov 23, 2026
): fixes the coordinator CPU spin (#917) Backports [transact-rs/sqlx#4289](transact-rs/sqlx#4289), "fix(pool): prevent num_idle underflow that wedges maintenance in a CPU spin" (merge commit `5d3787ef9d69947065085f46b58767a50b3d8e25`, merged 2026-09-10, first released in sqlx 0.9.1 on 2026-11-18), into the sqlx-core 0.8.6 that #794 vendored. It is in neither 0.8.6 nor 0.9.0. ## Observed in production A production PRISM v3.1.1 coordinator stalled repeatedly, for minutes to hours at a time. One tokio worker thread sits at 100% user CPU and never enters a syscall, while every other thread waits. A read-only `perf` sample put 100% of that thread's samples in: - `sqlx_core::pool::inner::spawn_maintenance_tasks::{closure#1}` - `ArrayQueue<Idle<Postgres>>::pop` - `tokio::sync::batch_semaphore::Semaphore::add_permits_locked` That is the pool's maintenance sweep, `for _ in 0..pool.num_idle()`, running on an empty idle queue with `num_idle` wrapped to about `usize::MAX`. 0.8.6's `release()` pushes a connection onto the idle queue and releases its permit before it adds one to `num_idle`, while `pop_idle()` pops and then subtracts one. An acquire that lands between the two subtracts first, and with the count at 0 it wraps until the add lands. The maintenance task reads the count once as its loop bound. With the queue empty the loop body never awaits, so a task that read the wrapped count keeps its worker for good. The stalls recur on a 30-minute rhythm, because every connection reopens together after each stall and they all reach the 30-minute `max_lifetime` together. ## The change `vendor/sqlx-core/src/pool/inner.rs` takes upstream's diff: - `release()` adds to `num_idle` before it pushes the connection; - `pop_idle()` subtracts saturating at 0; - the maintenance sweep makes at most `min(num_idle(), max_connections)` checks. Those three code changes are upstream's, line for line (the added and removed lines of the hunks diff empty against upstream's commit). Nothing else in the vendored crate's code changes. Upstream's stress test, `underflow_tests`, comes with them. It needed two adaptations to build and run on 0.8.6, both recorded in `vendor/sqlx-core/README.md`: - its stub backend takes 0.8.6's `AnyConnectionBackend` signatures (`&str` and `Cow<'static, str>` where 0.9 has `SqlStr`, and `describe` without the `offline` gate); - its pool sets neither `max_lifetime` nor `idle_timeout`, so that it spawns no maintenance task and needs no runtime. `vendor/sqlx-core/README.md` gains the #4289 entry in the style of #4251's and #3861's. ## Test evidence Upstream's test, run from a copy of the vendored crate with `cargo test --lib --features any,_rt-tokio underflow` (12 threads, 200,000 acquire and release cycles each, on a pool of 3): | Pool code | Debug | Release | | --- | --- | --- | | 0.8.6 as vendored before this change | 5 of 5 fail: `saw 18446744073709551615, max 3` | 3 of 3 fail, same message | | with this change | 5 of 5 pass | 3 of 3 pass | Also run locally: - `cargo check --lib --features _rt-tokio,_tls-rustls-ring-webpki,json,chrono,migrate` on the patched crate: clean, with only the three warnings upstream ships; - `python3 scripts/check_vendored_sqlx_core.py`: both lock files use `vendor/sqlx-core` 0.8.6, 0 advisories; - `python3 -m unittest tests.test_check_vendored_sqlx_core`: 11 tests pass. Not run locally: the workspace build and test suites. The host had 1.6 GB of disk free, so CI is the first full build of this. ## What this does not cover - **CI does not run upstream's test.** It is a unit test inside sqlx-core, and Cargo tests only workspace members. The README says how to run it. Nothing in CI fails if these hunks are lost; a regression test through the public pool API in `crates/qbit-prism-server/tests/`, as #4251 and #3861 have, would close that. - **The sweep cap has no test of its own**, upstream's included: with the reordering in place the count cannot wrap, so the cap is never reached. - **No version bump, tag or release.** `VERSION` stays 3.1.1. - **Release notes.** The pending 3.1.2 notes in #897 need an entry for this fix; this PR adds none, as `main` has no unreleased notes file. - **3.x.x.** The fix reaches 3.x.x by merging `main` into it after this lands. There, #836's source check requires the change recorded as a patch in `vendor/sqlx-core.patches/`, and the README has diverged, so that merge needs both resolved. Refs #794. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Squashed commits: 192603d main: backport sqlx's pool num_idle underflow fix (transact-rs/sqlx#4289): fixes the coordinator CPU spin 6db3769 vendor/sqlx-core/README.md: say what the #4289 backport is for without deployment details Squashed-from: 6db3769 Co-authored-by: Claude Fable 5.2 <[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.
Problem
Nothing in the repository yet tells a 3.1.1 operator what 3.1.2 changes for them.
VERSIONis 3.1.1 and there is nodoc/release-notes-3.1.2.md. Three things in particular are silent today:.envlines an existing deployment keeps. 3.1.1's.env.exampleshippedPRISM_STRATUM_MAX_AUTHORIZE_ATTEMPTS_PER_INTERVAL=0(git show d0c649b4:.env.example, line 353). An explicit value wins over the new default of 32 (stratum.rs:341,compose.yaml:595:-32), so an.envcopied from it keeps the authorize budget off. LikewiseQBIT_GIT_REF/QBIT_GIT_COMMIT:scripts/prepare-qbit-source.shandscripts/check-env.shread.envafterconfig/upstream.env, so such an.envkeeps building Qbit Core v1.0.0 andmake doctorreports it verified.qbit_prism_payout_revision_listener_upas down (… or on(job, instance, network) (max_over_time(up[2m]) == bool 1)), and 3.1.1 doesn't export that gauge. Deployed before the last 3.1.1 frontend is gone, or left in place after a rollback, it warns on every 3.1.1 frontend that serves miners. 3.1.1's notes said its rules "need no change if the binaries roll back"; that is no longer true.DuplicatePoolFeeAccount,d0c649b4:crates/qbit-prism/src/lib.rs:1650), andAUDIT_BUILDER_VERSIONstays 1, so the builder-version guard (stored_inputs_mismatch) doesn't stop a 3.1.1 frontend from trying. Its rebuild error propagates out ofrebuild_claim_parts(build.await??) throughland_offeredtosettle_offered_candidate, which parks the row inreconciliationwithALERT: offered candidate could not be processed; kept for reconciliation, never offered againand aLEAST(3600, 10*attempt_count)s backoff. A 3.1.1 dual-writer node's adoption (adoption.rs,build_claim_parts) and 3.1.1's verifier refuse it the same way. Nothing says so.And the HA failover runbook promises that a block mid-landing "lands within seconds of the move", which isn't true when the fence leaves established ledger connections silent: the ledger pool sets no TCP keepalive or user timeout (
ledger/connect.rspool options; the vendored socket sets onlyTCP_NODELAY; sqlx's releasepinghas no timeout).Change
doc/release-notes-3.1.2.md(new, undated as 3.x.x: version 3.1.1 and its release notes #810 left 3.1.1's): every pull request merged into3.x.xsincev3.1.1(git log --first-parent d0c649b4..af448068: 26 merges, plus 3.x.x: work on the pool fee's own program is settled in the fee output, so it can no longer fail template builds (#822) #827 and 3.x.x: mining.authorize is bounded by default: 32 attempts per session, one node validation per payout address and at most four at once per frontend (#823) #828 squashed and 3.x.x: record the released main as a parent, and land synchronization PRs by fast-forward #831's two commits), in 3.1.1's structure. Changes since 3.1.1 by area; Settings, Database connections, Metrics, Alert rules, API behaviour; Upgrading (from 3.1.1, with the mixed 3.1.1/3.1.2 cluster and dual-writer mode, and from 3.1.0, 3.0 and 2.0.x); Rolling back; Verification; Known issues; and, under "Still in review, not yet described", 3.x.x: issued-job saves run up to two batch transactions at once, in waves, so a new tip's fan-out is no longer one transaction at a time (#860) #868, 3.x.x: the dependency audit accepts chrono's unmaintained advisory (RUSTSEC-2026-0543) until chrono is replaced (#878) #880, the pull requests for 3.x.x: bound difficulty-hint statements on the server, so a write past its 500 ms bound does not keep running (follow-up to #856) #872 and PrismPayoutRevisionListenerDown: its 2-minute smoothing ends a minute before PrismMetricsEndpointDown's 3-minute dwell #869, and the six this wave opens, for the release coordinator to replace.docs/prism-ha-reference-architecture.md, failover step 5: restart both frontends after moving the writer endpoint, unless the move resets every established connection, as a precaution for an unclean loss whose fence leaves those connections silent. The "within seconds" claim now holds only for a move that reset them. The 15-minute figure is attributed to the kernel's documentation oftcp_retries2, not stated as measured.docs/prism-ledger-ops.md: a new subsection, "Work paid to the pool-fee address during a 3.1.1 to 3.1.2 upgrade (Review finding: a miner using the pool-fee program can fail template builds #822)", next to the 3.x.x: a payout-revision race during the post-offer landing raises 'offered candidate could not be processed' about twice per 30 minutes #630 runbook that documents the same ALERT; a pointer from the pool-fee procedure's Review finding: a miner using the pool-fee program can fail template builds #822 sentence; and a sentence in "HA database and shutdown" pointing to step 5. The offer-lifecycle table and "Retry, replay and deadline contract" are untouched.PRISM.md: its Review finding: a miner using the pool-fee program can fail template builds #822 sentence points to that subsection.docs/prism-configuration.md: an explicit=0from an older.env.examplewins over the new authorize default; what a breach looks like; the proxy case.docs/prism-alert-migration.md(prose only): roll the listener rule back before the binaries; an adoption note for 3.x.x: alert when share appends queue for an append slot (follow-up to #829's stage metric) #844'sPrismShareAppendAdmissionWaitHigh, which stays quiet on a frontend without the stage histogram. The generated tables are unchanged, andgenerate_prism_alerts.py --check's prose checks still pass.docs/prism-rust-migration.md: its HA section points to step 5.Not touched, as the task says:
VERSION,Cargo.toml, the lockfiles, the README banner, the development line's status,docs/releasing.md,.github/**and every generated file.Confirmed in the code, and where the findings differ
Every default, refusal, metric, rule and precedence claim in the notes was traced to its code at
af448068. Where the research findings and the code differ, the notes follow the code:remember_at): past the hour, then entries whose payout address isn't the typed text, then entries older than 5 minutes, then everything. The finding and 3.x.x: mining.authorize is bounded by default: 32 attempts per session, one node validation per payout address and at most four at once per frontend (#823) #828's docs said fallback entries went before "the others"; the notes and the configuration guide now follow the code.payout_identity.rs,VALIDATION_WAIT), not only the slot.network_lifetime,docs/public-dashboard-api/README.md).PRISM_DATABASE_URL's parse is new. The public reader's URL and the peer URLs were already parsed with the client's parser in 3.1.1; what is new for them is theverify-cacheck. A fewtools.rscommands read the URLs directly and still fail only at connect; the notes name them.Landing::Refusedpath's "could not land". The finding's text is right. It needs no frontend failure:claim_lane_sqltakes whichever unclaimed row is due, so a 3.1.1 frontend can claim, offer and then fail to land a block a 3.1.2 frontend found.PEER_SESSION_OPTIONS'tcp_keepalives_*andtcp_user_timeoutare PostgreSQL session settings, which let the peer's server notice a vanished client. They don't bound the client's own wait, so they are no client-side precedent. This doesn't change the runbook step.compose.yamlusesrestart: on-failurefor the frontends andcompose.production.yamlusesunless-stopped. Neither restarts a running container, which is what the runbook says.ledger/window.rs,refused_for_want_of_a_partition) still matches PostgreSQL's English message. 3.x.x: tell statement timeouts from cancels by SQLSTATE and time, not PostgreSQL's English message (#824) #852's own body says so, and the notes list it as still open.make doctorwarning for=0(code, out of scope). Also not done: the dev-line status, README banner anddocs/releasing.md:4, which the version PR and another writer own.Tests
All on this head, from the worktree:
python3 scripts/check_version_skew.pypython3 scripts/generate_prism_alerts.py --checkprism-alert-migration.mdandprism-ledger-ops.mdpython3 scripts/generate_prism_metrics.py --checkpython3 scripts/check_prism_settings.pypython3 scripts/check_prism_alert_uids.pyGIT_CONFIG_GLOBAL=/dev/null python3 -m unittestover the 21tests/test_*.pymodules that readdocs/,doc/or Markdown (test_docs_lab_prism_references,test_check_deleted_test_map,test_check_prism_alert_uids,test_check_prism_settings,test_prism_generated_artifact_checks,test_mainnet_compose_contract,test_check_gate_manifest,test_tree_pass_marker,test_check_version_skew,test_makefile_lifecycle,test_check_vendored_sqlx_core,test_ckpool_rejects_patch,test_prism_load_bridge,test_prism_load_probe,test_prism_load_regress,test_dual_writer_matrix_summary,test_prism_load_trend,test_run_rust_test_shard,test_run_python_test_shard,test_prism_shipped_image_lane,test_prism_soak_capture)<a id>inprism-rust-migration.mdthat predates this change and is validgit diff --check/code-review xhighin an Opus subagent, before the first push.envkeeps three lines, not two; only the listener rule must follow rollbacks; the tag goes on the promotion intomain;If-None-Match: *still answers 304; 924.6 s is the kernel's lower bound; the cache-eviction order now matchesremember_at; the restart command uses the deployment's Compose files and project; the dual-writer "together" reason was inconsistent and is dropped; long lines reflowed. Not taken: setting keepalives in the ledger's sockets (code, finding C's part (b), planned for 3.1.3), and folding the repeated #822 explanation into one place (the notes stay self-contained; the copies now agree)Not run, and not verified
test_check_vendored_sqlx_core's real-tree tests skip locally withoutSQLX_CORE_UPSTREAM_CRATE..github/rulesets/as the files say; the "no ruleset requires CI" statement rests on those files and their README.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.