Repository navigation
3.x.x: stream the recovery-evidence export with FETCH_COUNT in the script, the runbooks and the rehearsal harness (#705) - #706
Merged
Conversation
…ript, the runbooks and the rehearsal harness (#705) Without FETCH_COUNT, psql buffers a whole result set before printing a row. On the restored production copy (65.9M shares) the documented export reached 63 GB RSS and was OOM-killed twice on a 62 GB host. With FETCH_COUNT=10000 it streams through a cursor at about 4 MB. The script now sets FETCH_COUNT itself, so every psql caller streams, and the five runbook commands pass it explicitly, with the reason. The cutover rehearsal harness ran the same psql without it and also collected all of psql's stdout in memory before writing it to a file; it now passes the flag and streams stdout straight into the file. tokio's output() always pipes stdout, so the harness spawns and waits instead. No server code changes. A cursor fetch changes how rows are delivered, not what they are, so the evidence output is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…time, and plan cursors for the whole result (#705) Review follow-ups. The script now sets FETCH_COUNT only when the caller left it unset, so -v FETCH_COUNT=<rows> can lower the batch size. FETCH_COUNT counts rows, not bytes, so the audit_bodies and audit_snapshots exports, whose rows can be megabytes, fetch 16 rows at a time and then restore the caller's value. psql 16 and older batch through a cursor, which the planner otherwise optimizes for its first 10% of rows; SET LOCAL cursor_tuple_fraction = 1.0 keeps the ordinary whole-result plans. The comments warn that those psql versions batch only statements starting with SELECT or VALUES. The rehearsal harness no longer passes its own FETCH_COUNT, so it runs the script's default. A new check in the frozen 2.x backup and restore test exports one row per fetch and requires the same evidence, so every result crosses batch boundaries. 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. |
This was referenced Oct 6, 2026
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) and the legacy-audit-body sidecar tool (#715). Cargo.lock and the fuzz crate's lock move only their workspace-member entries. doc/release-notes-3.0.0-rc.2.md covers: - the changes since rc.1: 025's per-program carry-forward rule, the canonical sidecars for escaped legacy range digests, FETCH_COUNT for the recovery evidence (#706), and the harness and CI fixes; - upgrading from 2.0.x and from rc.1; - the lean verification, since the only runtime change is 025; - the known issues. The development-line notes name 3.0.0-rc.2 as the tree's identity, and they and the 3.0.0 notes link both candidates' notes. U3 wrote the change lines. 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.
Fixes #705 (close by hand: the base is not the default branch).
Problem
Without
FETCH_COUNT, psql buffers a whole result set before printing a row. On the restored production copy (65.9M shares), the documented recovery-evidence export reached 63 GB RSS and was OOM-killed twice on a 62 GB host. With-v FETCH_COUNT=10000the same export ran at about 4 MB.The cutover rehearsal harness (
make prism-cutover-rehearsal, which #291's C1 runs) had the same problem twice over:FETCH_COUNT;Change
scripts/prism-recovery-evidence.sql:FETCH_COUNTto 10000 when the caller left it unset (0), so every psql caller streams. A caller's-v FETCH_COUNT=<rows>is kept.FETCH_COUNTcounts rows, not bytes, so theaudit_bodiesandaudit_snapshotsexports, whose rows can be megabytes, fetch 16 rows at a time and then restore the caller's value.SET LOCAL cursor_tuple_fraction = 1.0: psql 16 and older batch through a cursor, and this keeps the planner on whole-result plans instead of first-rows plans.SELECTorVALUES.docs/prism-ledger-ops.mdanddocs/prism-rust-migration.mdpass-v FETCH_COUNT=10000and say why. The flag covers script copies from before this change, such as the rc.1 tag's.tests/support/recovery.rs): psql's stdout streams straight into the temp file. tokio'soutput()always pipes stdout, so the harness spawns and waits instead. It runs the script's own default.No server code changes. Batching changes how rows are delivered, not what they are.
Tests
On a private PostgreSQL 16.10, at the branch head:
cargo test -p qbit-prism-server --test migration_rollback: 10 passed, 2 ignored (operator and generator modes). This includes the mainnet-shaped cutover rehearsal and the newFETCH_COUNT=1equality check.cargo test -p qbit-prism-server --lib recovery_evidence: 2 passed. These tests parse the script.cargo clippy -p qbit-prism-server --test migration_rollback --test live_regtest -- -D warningsandcargo fmt --check: clean.FETCH_COUNT;/code-review highran on the first commit; its findings are addressed in the second.Merge timing: after the
v3.0.0-rc.1tag, per the rc.1 freeze, unless the coordinator folds it into #703. Until then, operators pass-v FETCH_COUNT=10000by hand, and runmake prism-cutover-rehearsalat production size from this branch.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.