Repository navigation
3.x.x: map 002's legacy share hashes after the migration transaction, in bounded batches with a durable cursor, and record 2 last (#582) - #663
Merged
Conversation
… in bounded batches with a durable cursor, and record 2 last (#582) Migration 002 backfilled qbit_prism_share_hashes with one INSERT ... SELECT DISTINCT ON over every accepted share, inside migrate's transaction and under its statement timeout. At the default 15 s it failed from about a million shares. At 4.13M it took 321 s of the 600 s cap, with a per-share cost that kept rising, so the production ledger (65.5M shares) could not be migrated with any allowed setting. 002's file now ends at the table. A fresh or empty source records 2 in the transaction as before. A populated 2.x.x source gets a one-row cursor, qbit_prism_share_hash_backfill (next_seq, end_seq), in the transaction, and 2 is not recorded there. After the commit, before 013 and 017, the runner in ledger/migration/share_hashes.rs maps the legacy shares in batches of consecutive share_seq, under the online runner lock. Each batch is 002's statement restricted to its range: one statement, in a transaction that also advances the cursor, sized toward 500 ms under the server's own statement timeout. The last transaction checks, under the migration lock, that the cursor has passed every row, then drops the cursor and records 2. The mapping is the single statement's, row for row: batches run in ascending order with DISTINCT ON inside each, and ON CONFLICT DO NOTHING applies across them. Until 2 is recorded, every start refuses the database, this build's and every earlier one's. The 2.x.x writer is fenced by 002's lease trigger. So nothing is appended while legacy headers are unmapped, and the append path is unchanged. require_schema_version names the cursor in its refusal, even if 2 was recorded by hand. An interrupted migrate resumes at the cursor: the native path accepts 3 without 2 when the cursor table exists, and still refuses it otherwise. A 2.x.x source that already holds the cursor's name is refused before any DDL. Tests: - The batched mapping equals the single statement's on a ledger that repeats headers across batch boundaries in upper case, with gaps, rejected rows, non-hex IDs and bare 64-digit IDs. - A run killed mid-batch leaves the last committed cursor; starts refuse the database; migrate then resumes to the exact mapping. - A held cursor name is refused before any DDL. - The weekly mainnet-shaped scenario drops its 600 s override and its #582 expected-failure check, returns to 1/16 density, and requires the backfill step. - The cutover rehearsal reports the backfill as its own step. Measured on a mainnet-shaped ledger of 8.25M shares at the default 15 s timeout, migrate completes in 462 s. The backfill takes 348-413 s at PostgreSQL's default memory settings, and 251 s with shared_buffers 4GB and max_wal_size 32GB. docs/prism-rust-migration.md has the section, the readiness rule and the sizing. 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. |
…update the weekly job's #582 note (#582) The runner re-reads the ledger's end under the migration lock before it records 2. A row past the end the cursor was planned to is mapped by another pass, not left unmapped. Nothing appends before 2 is recorded, so only a writer that went around every gate could put one there; the new test inserts one while the backfill waits on the runner lock, and checks that it is mapped and the cursor is dropped. The weekly live-regtest job's comment now describes the scenario as it runs after #582: 1/16 of mainnet's rows, about 4.1M, cut over at the server's default statement timeout. No job, step or setting changes. The first push of this PR left the comment out: the token then lacked the workflow scope (#665). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…its locks, and refuse a pending cursor in the evidence export (#582) From /code-review high on the backfill: - Batch size counts share_seq values, not rows. After a gap or a run of rejected shares, batches are cheap and grew to 200,000, and the next dense range could outlast the statement timeout. BATCH_MAX is now 50,000, under 4 s at the slowest measured rate. A batch that times out all the same is rolled back and retried at half the size; an operator's cancel request (same SQLSTATE, another message) still stops the run. - The recording transaction ran under the pool's 5 s lock timeout after all the mapping was done. Like 013's and 017's records, it now waits for the migration lock and for readers of the cursor table. - The recovery evidence export refuses while qbit_prism_share_hash_backfill exists, as startup does, so a hand-recorded 2 cannot export a partial mapping. The metadata regression checks it. - A start that takes no lock could find the cursor table, then lose it to the recording transaction's DROP. progress() reads that as complete rather than failing with 42P01. A non-table under the cursor's name is refused by name. One catalog probe serves both checks. - The cursor records start_seq. The refusal and the documented percent query state the mapped and unmapped share_seq ranges instead of reading end_seq as a count. - Each batch checks the cursor with a conditional UPDATE after the insert, instead of a separate SELECT ... FOR UPDATE. - The interrupt test terminates the waiting batch first and asserts the durable state afterwards, so the batch's own lock timeout cannot race it on a slow runner. - The docs warn against running an earlier 3.x.x build while the backfill is pending: its remedy for 3 without 2 is to record 2 by hand. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member
Author
|
Earlier in the PR, 31396e9 added a test for the runner's "rows past the planned end" pass and restored the weekly job's comment, which needed workflow scope; #665 is closed. |
This was referenced Oct 5, 2026
RobertClarke
added a commit
that referenced
this pull request
Oct 5, 2026
…runners' lock, so an earlier runner cannot leave one behind (#669) Codex (P1) and /code-review high on #681: a resume declared the fence in its migration transaction, which does not take the runners' lock. A runner of a #663-era build that was still mapping could then finish, drop the cursor and record 2 without knowing the fence. This release's runner, queued behind it, found 2 recorded and returned, and the orphaned fence would have locked out a fully mapped ledger. - The migration transaction now declares the fence only for a cursor it creates itself. - A runner that resumes the backfill declares it again before its first batch, after acquiring the runners' lock. An earlier runner holding that lock has finished by then, and no fence is declared that it would leave. - The native path reads the fence from the validated capability inventory (inspect_source_schema). This replaces a second, weaker lookup, and its own cursor probe gives way to a flag set where the cursor is created. - The orphaned-fence refusal now offers a verified way out besides the full restore: remove the declaration once qbit_prism_share_hashes is shown to map every legacy header. The docs give the query. - The docs and release notes say precisely how earlier builds react: a pre-#582 build's first migrate still suggests recording 2, which changes nothing. Tests: - A new test plays the earlier runner: it holds the runners' lock while a resume's transaction commits, then finishes the backfill without touching capabilities. The resume declares no fence meanwhile, and the database starts afterwards. - The lifecycle test watches the resume's runner declare the fence again while a batch waits on an open insert, before removing it with the cursor. Co-Authored-By: Claude Opus 5.5 <[email protected]>
RobertClarke
added a commit
that referenced
this pull request
Oct 6, 2026
…e share_hash_backfill_pending capability, so recording 2 by hand cannot let one serve (#669) (#681) * 3.x.x: fence earlier builds off a pending share-hash backfill with the share_hash_backfill_pending capability, so recording 2 by hand cannot let one serve (#669) #582 records migration 2 only after 002's share-hash backfill. Every start refuses the database until then, because every build requires 2. But an earlier build that meets 3 without 2 tells the operator to record 2 by hand once 002's objects are present, and then it would serve with legacy headers unmapped. The docs said never to do that; nothing enforced it. While the backfill is pending, the database now declares the capability share_hash_backfill_pending = 1, using the standard capability mechanism: - The migration transaction that creates the cursor declares it, once 006 has created the capability table. - Every resume declares it again (ON CONFLICT DO NOTHING). So a backfill a #663-era build started, or one whose row was deleted, is fenced by the next migrate before its batches start. - The transaction that drops the cursor and records 2 removes it. It is the one capability native code removes, because it describes a state, not a format. Every build before #669 refuses it at connect and at migrate, whatever the migration record says. This release refuses the cursor itself, and so does the evidence export, so recording 2 by hand unlocks nothing. A declaration whose cursor is gone can only be left by dropping the cursor by hand. Every migrate refuses it before any DDL, with that cause instead of the "3 without 2, record it by hand" remedy. The connect gate and the recovery evidence export refuse it too. Tests: - An earlier build's capability list refuses the fence; this build's accepts it. - The evidence export's list of understood capabilities is pinned to NATIVE_CAPABILITIES. - Fence lifecycle: declared with the cursor; kept when 2 is recorded by hand, with starts still refused; declared again by a resume after a hand deletion; removed with the cursor when 2 is recorded. - A hand-dropped cursor leaves the fence, which migrate refuses; with 2 also recorded, migrate still refuses and the start finds 13 and 17 missing. - A fence on a fully migrated database is refused by every start and migrate. - The evidence export refuses a fence without its cursor. Co-Authored-By: Claude Opus 5.5 <[email protected]> * 3.x.x: declare a resumed backfill's fence from its runner, under the runners' lock, so an earlier runner cannot leave one behind (#669) Codex (P1) and /code-review high on #681: a resume declared the fence in its migration transaction, which does not take the runners' lock. A runner of a #663-era build that was still mapping could then finish, drop the cursor and record 2 without knowing the fence. This release's runner, queued behind it, found 2 recorded and returned, and the orphaned fence would have locked out a fully mapped ledger. - The migration transaction now declares the fence only for a cursor it creates itself. - A runner that resumes the backfill declares it again before its first batch, after acquiring the runners' lock. An earlier runner holding that lock has finished by then, and no fence is declared that it would leave. - The native path reads the fence from the validated capability inventory (inspect_source_schema). This replaces a second, weaker lookup, and its own cursor probe gives way to a flag set where the cursor is created. - The orphaned-fence refusal now offers a verified way out besides the full restore: remove the declaration once qbit_prism_share_hashes is shown to map every legacy header. The docs give the query. - The docs and release notes say precisely how earlier builds react: a pre-#582 build's first migrate still suggests recording 2, which changes nothing. Tests: - A new test plays the earlier runner: it holds the runners' lock while a resume's transaction commits, then finishes the backfill without touching capabilities. The resume declares no fence meanwhile, and the database starts afterwards. - The lifecycle test watches the resume's runner declare the fence again while a batch waits on an open insert, before removing it with the cursor. Co-Authored-By: Claude Opus 5.5 <[email protected]> * 3.x.x: declare the backfill fence only with its cursor, never on a resume, so it cannot meet an earlier build's runner (#669) Codex (P1) on 4f0f004: moving a resume's declaration into the runner, after the runners' lock, still left a race. An earlier build's migrate that passed its capability check before the fence existed can queue for the lock. If this release's runner declares the fence and then stops on an error, a cancel or a restart, the queued earlier runner finishes the backfill, drops the cursor and records 2 without removing a fence it does not know. Every later start and migrate would then refuse the database. The fence is now declared only by the migration transaction that creates the cursor, never on a resume. Migrations serialize on the migration lock, and no earlier build's migrate passes its capability check once the fence has committed. So a fence never coexists with an earlier build's runner: any runner an earlier build started belongs to a cursor an earlier build created, which carries no fence. The price is that a backfill a #582 build started stays unfenced to its end; the docs say so. Tests: - New: a resume of an unfenced backfill crashes mid-batch without declaring a fence. The test then plays the earlier runner finishing the backfill, and migrate and starts succeed afterwards. - The lifecycle test sees the creation-time fence held through a resume's batches and removed with the cursor. Co-Authored-By: Claude Opus 5.5 <[email protected]> * 3.x.x: drop an unneeded mut from the fence lifecycle test (#669) 7671768's rewrite left the blocker transaction mutable, but it only rolls back, and clippy -D warnings refuses that. Co-Authored-By: Claude Opus 5.5 <[email protected]> * 3.x.x: say the backfill fence covers only backfills started from #669 on (#669) Codex (P2) on 7671768: the release note read as if every pending backfill were fenced. A backfill that a #582 build started before #669 carries no declaration, and a resume does not add one, so recording 2 by hand could still let a pre-#582 build start with legacy headers unmapped. The note now says so, and the guide's list of how earlier builds react says it describes a fenced backfill. Co-Authored-By: Claude Opus 5.5 <[email protected]> * 3.x.x: bring the fence's comments in line with its creation-only declaration (#669) One test's doc still said a resume declares the fence from its runner, which 7671768 removed, and the migrator's comments said a resumed backfill is never fenced "again", which is wrong for a cursor an earlier build created. Co-Authored-By: Claude Opus 5.5 <[email protected]> * 3.x.x: refuse a newer release's share_hash_backfill_pending as newer, never as an orphaned fence to delete (#669) Codex (P2) on c20fdf2: on migrate's native path, the orphaned-fence check matched the capability by name and ran before refuse_newer_native_database. A newer release that declares share_hash_backfill_pending at another value, with no cursor, was told its declaration was an orphaned fence = 1. The remedy offered was to delete it after checking only the old share mapping, which could remove that release's own safety declaration instead of saying "upgrade the server". The native path now validates capability rows before it reads the record, as connect does. Then the orphan check, and the 3-without-2 check after it, only ever see values this release understands. The orphan check also matches value 1 exactly, here and at connect, where refuse_unknown_capabilities already ran first. The evidence export already raised on any other value inside its loop, before its own orphan check. Tests: both cursorless-fence tests now also raise the fence to 2. The migrated database is refused at start and at migrate as a newer release's. In the 3-without-2 state, migrate refuses it the same way, naming neither the orphan nor the record. Both fail on c20fdf2. Co-Authored-By: Claude Opus 5.5 <[email protected]> * 3.x.x: qualify the guide's capability narrative for backfills a #582 build started (#669) The narrative said every earlier build is refused for as long as legacy headers are unmapped. That holds only for a backfill this release started: one a #582 build started carries no declaration, as the backfill section and the release note (37b56cc) already say. Co-Authored-By: Claude Opus 5.5 <[email protected]> * 3.x.x: keep migrate's capability checks in their order, matching only value 1 as an orphaned fence (#669) e05038c moved refuse_newer_native_database ahead of refuse_undeclared_native_database and the record check, so the fence's name at a newer release's value would be refused as newer. That broke offer_lifecycle's migrated_database_without_its_offer_lifecycle_declaration_is_refused_at_connect_and_at_migrate (CI shard 2). An edited candidate_offer_lifecycle = 0 must be refused as an edited declaration, before the newer check, as connect refuses it, and it was refused as "a newer PRISM release wrote this database". The order is back as it was. The orphaned-fence check still matches value 1 only, which is Codex's other remedy: at another value the name is a newer release's declaration, refused as any newer capability is and never offered for deletion. A migrated database gets "upgrade the server". With 3 recorded and not 2, the record's refusal comes first, as it does for any newer capability, and the next migrate after 2 is recorded refuses the value as newer. The cursorless-fence test now probes value 2 in both record states; set_fence replaces the inline updates. Co-Authored-By: Claude Opus 5.5 <[email protected]> * 3.x.x: leave a newer release's backfill fence, cursor and record to it, reading the fence again before recording 2 (#669) Codex (P2) on 1d3843b: the runner maps between holds of the migration lock, so a newer release's migrate can commit meanwhile. If that release declares share_hash_backfill_pending at its own value, the final transaction deleted the declaration by name, dropped the cursor and recorded 2, defeating that release's fence. The final transaction now reads the fence again under the migration lock. Absent (a cursor an earlier build created) or 1, it records 2 as before. At any other value it refuses, naming the value, and leaves the cursor, the declaration and the record to the newer release; this release's next migrate refuses the value as newer. Test: a_runner_leaves_a_newer_releases_fence_with_its_cursor_and_record holds a resume's batch on an open insert, declares the fence at 2 as a newer release would, and then requires the runner to refuse with the cursor, the value and the record untouched. It fails on 1d3843b. The guide's fence section and its refusals table describe the check. Co-Authored-By: Claude Opus 5.5 <[email protected]> * 3.x.x: rewrap a fence test comment after 024 (#669) Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
RobertClarke
added a commit
that referenced
this pull request
Oct 6, 2026
#551, #553, #554, #582) The file is 3.x.x's copy byte for byte again, as of 3.x.x c95febb; the last change to it there is bd1ddeb (#663). Since 1932cb3 (#597), five 3.x.x changes landed in it: - #552 (#613): the `bridging` job runs the short plan on the fake and the real node on one runner, nightly, on the run-load label and on a dispatch with the new `bridging` input. - #551 (#606): every preset job builds a trend row; on a schedule the `evidence` job (the one job with `contents: write`) appends the rows to the orphan `ci-evidence` branch, applies the report-only regression rule, promotes the soak's and flagged runs' bundles to the rolling `ci-evidence/YYYY-MM` pre-release, and keeps one `prism-load-regression` issue. PR and dispatch runs get the read-only `evidence-preview` instead. - #553 (#618): the live nightly and weekly lists gain the chain-event scenarios under 2,000 sessions; the workflow's comments say so. - #554 (#635): the run job installs fuse2fs and fuse3 for a preset whose faults fill the WAL volume (faults-long-real-node, Saturday). - #582 (#663): comment only. Without this, main's scheduled copy (#595) still has no qbitd install step, so every `--node qbitd` preset fails with "--node qbitd needs --qbitd-bin or QBITD_BIN" (scheduled runs 37188928798 and 37287515779). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Anatolie
added a commit
that referenced
this pull request
Oct 16, 2026
(#590, #596, #588, #597, #552, #551, #553, #554) (#601) * main: sync the PRISM load-harness nightly workflow from 3.x.x (#590, #596) Co-Authored-By: Claude Opus 5.5 <[email protected]> * main: sync the PRISM load-harness nightly workflow from 3.x.x (#590, #596, #588, #597) Adds #588's Saturday 5.5 h soak schedule and its live-nightly step that runs every listed test binary, so qbit-prism-load::soak_smoke runs beside the live_regtest variants, and #597's L6 shipped-images lane on the Sunday schedule. Byte-identical to 3.x.x at 1932cb3. Co-Authored-By: Claude Opus 5.5 <[email protected]> * main: re-sync the PRISM load-harness nightly workflow from 3.x.x (#552, #551, #553, #554, #582) The file is 3.x.x's copy byte for byte again, as of 3.x.x c95febb; the last change to it there is bd1ddeb (#663). Since 1932cb3 (#597), five 3.x.x changes landed in it: - #552 (#613): the `bridging` job runs the short plan on the fake and the real node on one runner, nightly, on the run-load label and on a dispatch with the new `bridging` input. - #551 (#606): every preset job builds a trend row; on a schedule the `evidence` job (the one job with `contents: write`) appends the rows to the orphan `ci-evidence` branch, applies the report-only regression rule, promotes the soak's and flagged runs' bundles to the rolling `ci-evidence/YYYY-MM` pre-release, and keeps one `prism-load-regression` issue. PR and dispatch runs get the read-only `evidence-preview` instead. - #553 (#618): the live nightly and weekly lists gain the chain-event scenarios under 2,000 sessions; the workflow's comments say so. - #554 (#635): the run job installs fuse2fs and fuse3 for a preset whose faults fill the WAL volume (faults-long-real-node, Saturday). - #582 (#663): comment only. Without this, main's scheduled copy (#595) still has no qbitd install step, so every `--node qbitd` preset fails with "--node qbitd needs --qbitd-bin or QBITD_BIN" (scheduled runs 37188928798 and 37287515779). Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Robert Clarke <[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 #582.
Migration 002's share-hash backfill was one
INSERT ... SELECT DISTINCT ONover every accepted share, insidemigrate's transaction and under its statement timeout, somigratecould not complete on a production-sized ledger (about 65.5M shares) at any allowed setting. This makes the backfill an online, batched, resumable step that records 2 last, as the issue's option (a) and the recommendation in its comments propose.Design
qbit_prism_share_hash_backfill(start_seq,next_seq,end_seq,started_at,updated_at), covering everyshare_seqthe ledger holds. It does not record 2.ledger/migration/share_hashes.rs, through the existing online-migration entry point and runner lock) maps the legacy shares in batches of consecutiveshare_seq:[next_seq, upper): one statement, in a transaction that also advances the cursor;share_seq; later ones double or halve toward 500 ms, between 1,000 and 50,000;share_seqand each uses the originalDISTINCT ON ... ORDER BY header, share_seq. So the earliest share of a repeated legacy header is mapped by the batch that holds it, and later copies meetON CONFLICT DO NOTHING. A unit test pins the batch statement to the old single statement, less its range.migrateagain finds 3 recorded without 2 and the cursor table present. It applies nothing in the transaction and resumes atnext_seq; 013 and 017 follow.qbit_prism_share_hash_backfillis refused before any DDL.require_schema_versionnames the cursor in its refusal: "migration 2's share-hash backfill has not finished ... below share_seq X of the Y ...". It refuses the same way even if someone records 2 by hand while the table exists.self-checkandimport-auditsall go through that gate.scripts/prism-recovery-evidence.sql) refuses a pending cursor too.migratelogs the start, a progress line every 10 s (next_seq,end_seq, rows mapped,share_seq/s, estimated seconds left) and completion.migrateor rolled back by restoring the pre-migration backup.Tests
All local runs used PostgreSQL 16.15 with
fsyncon.New integration tests (
ledger_postgres::share_hash_backfill, registered intest/prism-gated-tests.txt):migration_002_maps_a_populated_2x_ledger_in_batches_as_its_single_statement_did:share_seqbelow or above it, so the pairs straddle batch boundaries and the earlier copy wins on either side. There are gaps inshare_seq, rejected rows, non-hex IDs and bare 64-digit IDs.migration_002_backfill_resumes_from_its_last_committed_batch_after_an_interrupt:pg_terminate_backend. Nothing of the killed batch survives, and starts still refuse, even with 2 recorded by hand.migrateresumes at the cursor, finishes with the exact full mapping, and records 2 before 013 and 017.migration_002_maps_a_row_past_its_planned_end_before_recording_2: the runner re-reads the ledger's end under the migration lock and maps a row that landed past it.migration_002_refuses_a_2x_source_holding_the_backfill_progress_name_before_any_ddl.migration_rollback's metadata regression: the evidence export refuses a pending cursor even with 2 recorded.Unit tests (
share_hashes.rs): the batch sizing bounds; the batch statement equals 002's single statement less its range; the refusal text.Existing suites:
cargo test -p qbit-prism-server --test ledger_postgres: 193 passed. That covers the 2.x.x upgrade, the 013 and 017 online-runner and legacy-duplicate tests, and the new ones.cargo test -p qbit-prism-server --lib: 639 passed.candidate_window_qualification::order_lock_hold_on_a_solve_does_not_grow_with_the_window, a timing threshold, on a debug build under heavy host load. It passes in isolation (hold growth −2.8 ms against 15 ms of slack). It uses a native ledger and never reaches 002.cargo clippy --locked --workspace --all-targets -- -D warningsandcargo fmt --check: clean.scripts/check_prism_pool_acquires.py: clean. The runner's twoconnection.begin()sites are registered as borrowed transactions, likepartition.rs.check_gate_env_reads.py, and the gate-manifest, acquire and docs-reference Python tests: clean.Measurements
Setup:
make prism-cutover-rehearsal-dump SCALE=1 DENSITY=…), each with all 13,566 blocks and 257 addresses.fsyncon.Official measured rehearsal on 8.25M shares (DENSITY=0.125;
make prism-cutover-rehearsal, private cluster at PostgreSQL defaults): PASS, every check. That covers recovery evidence, sums over 16 tables, 257 balances by SQL and by API, the 45,168-share payout window, frontend readiness, first job, self-check and audit completeness.qbit_prism_share_hashes; ACCESS EXCLUSIVE only on the cursor table, 11 msFor comparison, #582's 4.13M rehearsal held ACCESS EXCLUSIVE on
qbit_share_ledgerfor 346 s, with 002 alone at 321 s under a 600 s timeout.Before and after, same dump, same host. The unmodified
3.x.xmigrate, at the maximum allowed 600 s timeout, failed after 609 s in 002's single statement (canceling statement due to statement timeout), and its transaction rolled back. This PR completes the same ledger at the default 15 s.Backfill rate by size and settings. Each run is
qbit-prism-server migrateon a freshpg_restore, with the cursor sampled once a second; the reruns reset the database to "backfill pending".shared_buffers, 1 GBmax_wal_size)share_seq/s up to ~5M, ~13k/s aftershared_buffers=4GB,max_wal_size=32GB,checkpoint_timeout=30minwork_mem=64MBmigrate1,042 s, exit 0)shared_buffers(4.9 GB at 16.5M): checkpoints stop, and the OS cache serves the evicted pages.Extrapolation to 65.5M shares:
migrate: about 5 min for 013's builds; seconds for the transaction and 017.The one statement left in the transaction that can matter (#672, not changed here). 016's solver attribution makes one random index probe per block (13,566). It took about 0.1 s with its pages cached, and 29.7 s when every page came from a disk saturated by another bulk load. An earlier rehearsal on this host, run while I was generating another dump on the same disk, refused there at the 15 s default. So its cost scales with blocks, not shares, but a cold cache on a slow or busy disk can approach the default timeout. #672 proposes bounding it per statement. Until then, a production-host rehearsal that refuses in 016 can give
migrate60000 ms.Follow-ups
Docs
docs/prism-rust-migration.md:doc/release-notes-3.x.x-development-line.md: a 3.x.x: migration 002's share-hash backfill cannot complete on a production-sized ledger (statement timeout) #582 entry.test/e2e-scenarios.tomland.github/workflows/prism-load-nightly.yml: the weekly scenario's density and timeout notes.Downstream (SwapLabsInc/qbit-tools, testnet, PR #1143)
Once the play's bootstrap pin includes this change:
migratehit a statement timeout any more, so the 259,000 and 3,861,015 ceilings no longer describe anything.qbit_mining_pool_prism_3xx_backfill_ack_sharesis no longer needed.qbit_mining_pool_prism_3xx_migrate_statement_timeout_ms: leave it unset by default.migrate_timeout_secondsmust be at least 2 × the effective statement timeout was there for 002's single statement. It can go.qbit_mining_pool_prism_3xx_migrate_timeout_seconds(3600) for the whole command.migratenow runs 002's backfill, 013's builds and 017's validation after the commit, all inside the same command.migrateis resumable, not UNKNOWN.timeoutkill during the backfill, 013 or 017 leaves a state thatmigrateresumes.qbit_prism_share_hash_backfillexists (3 recorded, 2 not). 013 or 017 is pending when its version is missing.migrateinstead of stopping the lane as UNKNOWN. Starts keep refusing the database until it has finished, so a re-run is safe.RUST_LOG=qbit_prism_server=info,migratelogs a backfill line every 10 s withnext_seq,end_seq,share_seq/s and the seconds left.SELECT next_seq, end_seq FROM qbit_prism_share_hash_backfillshows the same, and the play could poll it.PRISM_REHEARSAL_291.md§8.1a: the decision table becomes "nothing to set at any size; budget the backfill time". 3.x.x: Cutover qualification — migration rehearsal, failover drill, soak, go/no-go #291's production-size rehearsal can run at the default timeout.🤖 Generated with Claude Code