Repository navigation
3.x.x: rehearse the 2.x.x cutover on a mainnet-shaped ledger and on a pg_dump, with each step's time and longest lock (#575) - #587
Merged
Conversation
… pg_dump, with each step's time and longest lock (#575) #575 item 1. Migrations were tested only on the synthetic schema_2x fixture. This adds a cutover rehearsal on #545's lifecycle scenario: - A seeded generator for a mainnet-shaped 2.x.x database, from the frozen release SQL. The shape is #521's aggregates: 257 identities over 76 days in three eras, a whale at 82-98% over a Zipf tail, bursty 5-minute rates (peak 394/s), and 13,566 blocks with signed audits in the three body layouts, PPLNS carry chains, payout entries, immature, inactive, reversed and rejected blocks, CTV rows, v1/v2 outbox rows, rollups and worker difficulty. Scale is 1x or 3x; a share-density knob thins rows only. #545's seed moves into the same module unchanged (byte-identical rows and files on equal inputs). - A rehearsal driver: check-config, migrate and import-audits exactly as the migration guide runs them, timed and with the longest lock per step sampled from pg_locks. It then checks the recovery evidence, every 2.x.x table's counts and sums, every address's balances (SQL and the running API), the payout window against the native snapshot, a first Stratum job and self-check. - Per PR, migration_rollback runs it on a pg_dump of a PR-sized mainnet-shaped ledger. The weekly live_regtest scenario cuts over 1x at 1/16 of the rows on a real regtest chain, then mines and reconciles as #545 does. - `make prism-cutover-rehearsal DUMP=... LEDGER_KEY=...` rehearses an operator's snapshot in a private PostgreSQL cluster and prints a pass/fail report. `make prism-cutover-rehearsal-dump` writes a mainnet-shaped dump, and `make prism-cutover-rehearsal-generated` does both in one command. All three are documented in the migration guide. - The weekly job builds in release and allows 120 minutes for the 1x/16 scenario. The rehearsal found #582: 002's share-hash backfill cannot finish within the migrate transaction's statement timeout on a production-sized ledger. The weekly scenario runs migrate at the 600 s maximum until it is fixed. It first asserts that migrate at the default timeout still refuses the ledger and changes nothing, so the check fails once #582 is fixed. Refs #575 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This comment has been minimized.
This comment has been minimized.
…r invariants, operator environment, dump formats (#575) Review findings on the cutover rehearsal: - The lock sampler now reports continuous holds: a lock released and taken again is two holds, keyed by relation OID and full advisory key. Online steps are recognised only by the statement that is the call, so 016's whole-file text no longer reads as 017's swap. The per-PR test no longer requires the millisecond 013/017 steps to have been sampled. - The native window is read as an operator tool, which registers no frontend heartbeat. It is compared in its own order with each share's credit policy, and must be non-empty. The per-PR ledger has 40 blocks, so the window spans more than one 4,096-row page of both readers. - The table facts now cover the pool rollups row by row, the writer lease, worker difficulty's update time, and every balance recomputed from the carry rows. They are read again after the frontend has run. The per-PR test checks that the restore reproduces the seeded source. - Operator mode: ENV_FILE runs the rehearsal with the operator's reviewed production environment. NODE_RPC could not pass: a mainnet node forces production mode, which refuses test keys. The private cluster requires a random password and is stopped even after a partial start. Directory, tar and plain dumps restore. Relative paths resolve from where make runs, and SCHEMA must be an identifier. The generator's pg_dump keeps the URL's other connection parameters. - Weekly: #545's carry-continuation check now also runs on the mainnet ledger. The #582 check runs from 2M rows (the 1x/16 ledger), says when it is skipped, and requires that no scratch schema or native table survived. The generator bounds its immature blocks. Refs #575 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member
Author
Review ledgerHead dff4634: a091b1a with 3.x.x merged in (#584, #592). CI is green on it: all four Rust PRISM shards, the gated-test proof, the Python shards and the aggregate check. Reviews run (proportionate for test and tooling work, as agreed):
Mutants, each failing the per-PR test on its own check:
Verification:
|
djh58
added a commit
that referenced
this pull request
Sep 29, 2026
Resolves test/prism-nightly-gated-tests.txt: keeps the soak smoke id and #586's clock-jump and disk-exhaustion ids, sorted. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
djh58
added a commit
that referenced
this pull request
Sep 29, 2026
This was referenced Sep 29, 2026
This was referenced Oct 1, 2026
Closed
3 tasks
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 #575 (item 1: cutover rehearsal on 2.x.x data). Found #582.
What
Until now, migrations were tested only on the synthetic
tests/fixtures/schema_2xfixture. This adds a cutover rehearsal on a mainnet-shaped 2.x.x ledger, built on #545's lifecycle scenario (#565):Generator (
tests/support/ledger_2x_seed.rs). A seeded, deterministic 2.x.x database from the frozen release SQL, in the shape of 3.x.x: pre-mainnet end-to-end scenarios on regtest, plus a nightly load-harness job #521's mainnet aggregates:scaleis 1 or 3.densitythins share rows only: each kept row carries 1/density of the difficulty, so work, window weight and balances keep the mainnet shape. 3.x.x: Migration lifecycle: a 2.x.x schema through migration, mining and rollback (#487 S20) #545's seed moves into the same module unchanged; a scratch harness showed byte-identical rows and audit files on equal inputs, and 3.x.x: Migration lifecycle: a 2.x.x schema through migration, mining and rollback (#487 S20) #545's weekly test passes on it.Driver (
tests/support/cutover_rehearsal.rs). It runscheck-config,migrateandimport-auditsas the migration guide does. Each step is timed, and a side connection samplespg_locksevery 10 ms for the longest lock per step (split into migrate's transaction, 013, 017 prepare/validate/swap, and the statements migrate spent most time in). It then checks:scripts/prism-recovery-evidence.*) is unchanged;/public/v1/miners/<address>;qbit_prism_windowagainst the native snapshot) and its prior balances;self-check.Per PR:
migration_rollback'scutover_rehearsal_tests::mainnet_shaped_2x_dump_rehearses_the_cutover_and_keeps_every_balancepg_dumps a PR-sized mainnet-shaped ledger (about 25k rows and 40 blocks, with a payout window of more than one 4,096-row page) and rehearses the dump through the operator path.Weekly:
live_regtest'sweekly_mainnet_shaped_2x_ledger_cuts_over_measured_mines_and_restores_in_isolation. It writes 1x at 1/16 of the rows over a real regtest chain, mined along the history's own timestamps. It then cuts over with the measured steps and checks, and mines, reconciles and rolls back as 3.x.x: Migration lifecycle: a 2.x.x schema through migration, mining and rollback (#487 S20) #545 does.Operator mode:
make prism-cutover-rehearsal DUMP=... LEDGER_KEY=...restores a supplied pg_dump (custom, directory, tar or plain format) into a private, password-protected PostgreSQL 16 cluster it creates and removes, rehearses it, and prints a PASS/FAIL report (JSON withREPORT=). By default it runs a lab configuration against a node that serves the dump's own chain.ENV_FILE=runs it with the operator's reviewed production environment instead, socheck-configandself-checkcheck the real configuration.make prism-cutover-rehearsal-dumpwrites a mainnet-shaped dump. Both are documented indocs/prism-rust-migration.md#rehearse-the-cutover-on-a-snapshot.test/e2e-scenarios.tomlgains thecutover-rehearsalscenario (lanepr).Finding
The rehearsal found that
migratecannot complete on a mainnet-sized 2.x.x ledger.002_multi_instance.sqlbackfillsqbit_prism_share_hasheswith one statement over every accepted share, inside the migration transaction, underPRISM_DATABASE_STATEMENT_TIMEOUT_MS(default 15 s, at most 600 s):migratefails with "canceling statement due to statement timeout";Tracked in #582. Until it is fixed, the weekly scenario runs
migrateat the 600 s maximum. It first asserts thatmigrateat the default timeout still refuses the ledger with this statement timeout and changes nothing, so the check fails as soon as #582 is fixed.Rerunning the rehearsal on a fix branch
One command writes a mainnet-shaped dump and rehearses it:
DENSITYis the fraction of mainnet's 65.5M share rows kept: 0.0625 is 4.1M rows, 0.015625 is 1.03M, and 1 is the full ledger (about 105 GB).SCALE=3is 3.x.x: pre-mainnet end-to-end scenarios on regtest, plus a nightly load-harness job #521's growth shape.STATEMENT_TIMEOUT_MSunset to rehearse the server's 15 s default.migratespent the most time in.The weekly scenario at a local density:
PRISM_REHEARSAL_WEEKLY_DENSITY=0.015625 cargo test --release -p qbit-prism-server --test live_regtest -- --ignored --exact migration_lifecycle_tests::weekly_mainnet_shaped_2x_ledger_cuts_over_measured_mines_and_restores_in_isolation --nocaptureVerification
prism-native-postgresshard, and no new test binary, so the shards are not reassigned.migration_rollbackpasses in full.make prism-cutover-rehearsalon generated dumps: 259k rows PASS in 122 s; 1.03M rows FAIL at the default statement timeout, as above, and PASS at 600 s.make prism-cutover-rehearsal-generated DENSITY=0.0625(4.13M rows) PASSES at 600 s in 640 s, of which 002 takes 321 s (timings on 3.x.x: migration 002's share-hash backfill cannot complete on a production-sized ledger (statement timeout) #582).cargo fmt --check,cargo clippy -p qbit-prism-server --all-targets -D warnings, shellcheck,check_gate_env_reads.py.Workflow
The weekly job needs
--releaseand a 120-minute timeout for the 1/16 scenario. That change toprism-load-nightly.ymlis pushed separately (it must stay identical on main and 3.x.x).🤖 Generated with Claude Code