Repository navigation
3.x.x: let the import admission gate run its integrity report on a hot standby, or skip it, under statement and lock timeouts (#738) - #740
Conversation
…t standby, or skip it, under statement and lock timeouts (#738) The gate's check 5 ran qbit_carry_forward_integrity_report() on the writer with no statement timeout. At production size the report takes about a minute, and a snapshot held that long on a primary with live miners piles up dead versions of the cluster row every share updates, which slows the share append's lock (#738). PRISM_INTEGRITY_REPORT_DATABASE_URL now runs the report on a hot standby instead. The gate refuses that URL when it is not in recovery, is not a replica of this writer's database (system identifier and database name), has hot_standby_feedback on, replicates a writer that waits for apply, or is stale: behind the writer and its last replayed transaction older than PRISM_INTEGRITY_REPORT_MAX_AGE_SECONDS (default 300). It records both WAL positions and warns unless replay is paused or both conflict delays are -1. PRISM_GATE_INTEGRITY=skip skips the check with a WARN. Every query now runs with a 15 s statement timeout and a 5 s lock timeout. The report gets 120 s on the writer and 600 s on a standby. A failed check names a statement timeout, lock timeout or recovery conflict without echoing psql's stderr, which can name the host. The standby's credential reaches psql through a subshell's environment, and a blank URL counts as unset. The Python shards already ran the gate's hermetic tests. Its real-schema tests now run in PostgreSQL shard 3, where a missing input fails them as it fails the gated Rust tests. 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: 427bf7c5cd
ℹ️ 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".
…caught-up shortcut (Codex on #740) After a failover a standby left on the old timeline keeps the writer's system identifier and database name, and its replay position can even compare as ahead of the new writer's. So positions are no longer used to call a standby fresh. The last replayed transaction's age always applies, since the live frontends' heartbeats keep the writer committing. The standby's timeline, from its WAL receiver when this role may read it and otherwise from its last restartpoint, must equal the writer's, taken from its current WAL file name. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 42d3436733
ℹ️ 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".
Set VERSION and [workspace.package].version to 3.0.0-rc.5: rc.4 plus #737's fixes in #742 (fatal-state clear accepts a tip that only grew, takes --timeout-seconds, and runs the integrity report under its own statement timeout) and #744 (migration 026: the report computes each set once); the deferred share-hash backfill in #743 and #746 (migrate --defer-share-hashes, then the throttled backfill-share-hashes after go-live); #745 (migrate --offline-indexes, which composes with --defer-share-hashes); the cutover tooling merged after rc.4's tag (#728, #732, #736, #740); and #747, a test-only fix for #724. Both Cargo.lock files move only their workspace-member entries. doc/release-notes-3.0.0-rc.5.md, dated 2026-10-08, covers: - the changes, with the report's estimated 57 to 29 s since 026, the migrate --defer-share-hashes command measured on the pair at 5 min 06 s (539d6c9, before #745), backfill-share-hashes' throttle, record of 2 and safe rerun, the evidence scripts' changes, and the offline index builds' estimated gain; - upgrading: migrate is needed again (a binary-only upgrade refuses "missing migration(s) 26", and this export refuses a database without 026), the cutover's migrate step with both flags, and finishing the backfill after go-live under #738's snapshot rule, with self-check only at low share rates. Rolling back to rc.4 at fence 2 goes only by finishing the backfill first or from the pre-migrate backup or physical copy, and each rc.4 refusal is quoted where it applies: a start meets the cursor first and says to run migrate, which rc.4's migrate refuses. The rules still in force: #737's statement timeout for rc.4's tools, 026 or not, #738's snapshot rule, and fatal-state clear --timeout-seconds, whose bound ends before the commit; - the same evidence set as rc.4's, with each PR's merge SHA, the pair's serving evidence carried, and the rehearsal's full measurements left to the cutover's go/no-go record; - the known issues: rc.4's, minus #737's F1, F2, F4 and F5, plus #737's open part, #738 (its fix planned for rc.6), #739, #741, #731 and #734, with #582 closed and #712 and #724 updated. docs/prism-rust-migration.md now says how earlier candidates refuse a database at fence 2: a start with the backfill's own refusal, whose advice to run migrate holds only for this release, and their migrate, or a start with PRISM_POSTGRES_INIT_SCHEMA=1, with the fence. The development-line notes name 3.0.0-rc.5, and they and the 3.0.0 notes link all five candidates' notes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Check 5 of
scripts/prism_legacy_import_admission_gate.sh(#736) ranqbit_carry_forward_integrity_report()on the writer, with no statement timeout. At production size the report takes about a minute (57–65 s on a 65.99M-share ledger). A snapshot held that long on a primary with live miners bloats the cluster row every share updates, and slows the share append'sORDER_LOCK(#738). So the gate has the same "below about 200 shares/s" limit asself-check. This PR lets the report run elsewhere, and bounds every query.Running the report on a standby:
PRISM_INTEGRITY_REPORT_DATABASE_URLruns check 5 on a hot standby. The gate refuses the URL when the standby:pg_control_system().system_identifierandcurrent_database()are compared on both connections. The writer's timeline, frompg_walfile_name(pg_current_wal_lsn()), must equal the standby's: its WAL receiver'sreceived_tliwhen the role may read it, else its last restartpoint's (Codex P1);hot_standby_feedbackon, so its report would hold back the writer anyway;synchronous_commit = remote_applywith synchronous standbys), where a pause stalls every commit;PRISM_INTEGRITY_REPORT_MAX_AGE_SECONDS(default 300). The live frontends' heartbeats keep the writer committing. The age is clamped at 0 against clock skew. WAL positions are recorded but never used to call a standby fresh: across timelines they aren't comparable.It records both WAL positions, and warns unless
pg_get_wal_replay_pause_state()ispaused, or bothmax_standby_streaming_delayandmax_standby_archive_delayare -1. A blank URL counts as unset. An unusable max age exits 2, like an unusable URL.Skipping:
PRISM_GATE_INTEGRITY=skipskips check 5 with a WARN and says so on the final line. It also says when a configured standby URL is therefore unused. Any other value fails.Timeouts (the gate's own; the frontends' 15 s
PRISM_DATABASE_STATEMENT_TIMEOUT_MSis too short for the report, #737):statement_timeout15 s andlock_timeout5 s (self-check bounds its completeness sample at 5 s);Credentials: the standby's password reaches psql through a subshell's environment, never argv. A standby URL without a password doesn't borrow the writer's.
Docs:
docs/prism-rust-migration.mdgives the same guidance as the script header.CI: the Python shards already discover the hermetic tests. The real-schema tests, which never ran in CI, now run in PostgreSQL shard 3, and there
PRISM_TEST_REQUIRE_INTEGRATION=1turns a missing input into a failure instead of a skip. That's how the recovery probe'sCASE WHEN pg_is_in_recovery()guard againstpg_get_wal_replay_pause_state()gets exercised on a real primary.Tooling only: no runtime code and no repin. The pinned gate changes sha256 (from
e1e1caee…), so the runbooks must pin the new bytes after merge.Review
Two
/code-review highpasses before pushing. They found 20 items; 18 are fixed here:remote_applyand pause-state checks;Declined:
Codex: the P1 on lineage (a divergent-timeline standby) is fixed in
42d34367.Testing
python3 -m unittest tests.test_prism_legacy_import_admission_gate: 35 hermetic tests pass. New ones cover:remote_apply;qbit-prism-server migratecreated: 2/2 pass, including a primary refused as the integrity standby.pg_wal_replay_pause(): no WARN, PASS;hot_standby_feedback = on: FAIL.bash -n. ShellCheck isn't available on this host.🤖 Generated with Claude Code