Repository navigation
3.x.x: attribute 016's block solvers in statements of at most 128 blocks, so the migration transaction stays inside the default statement timeout on a cold cache (#672) - #680
Merged
Conversation
…cks, so the migration transaction stays inside the default statement timeout on a cold cache (#672) Migration 016 fills qbit_pool_blocks.solver_* for the blocks a 2.x.x pool found before it, with one probe of qbit_share_ledger_accepted_block_suffix_idx per block (13,566 on mainnet). Its file ran that as one UPDATE ... CROSS JOIN LATERAL statement inside the migration transaction, under the statement timeout. Each probe is two random reads, so on a cold cache the statement grows with the ledger. On mainnet-shaped ledgers, from a quiet disk, it took 6.7 s at 8.25M shares and 11.2 s at 16.5M; under a concurrent writer it took 14.0 s at 8.25M; and #582's rehearsal on a saturated host saw it refused at the 15 s default. 016's file keeps its columns, landing trigger, catalog and functions, and loses the UPDATE. Right after the file, in the same transaction, the migrator makes the same probes in statements of at most 128 blocks, keyset-ordered by block_hash over the blocks without a solver (ledger/migration/block_solvers.rs). The attribution, locks and atomicity are unchanged, and a block whose solving share is not found keeps NULL columns. The longest statement measured 71-592 ms across those runs, and 0.47 s under the concurrent writer. Test: on a frozen 2.x.x source with 300 blocks (three statements), the attribution equals the old single statement's lookup, row for row. That covers the latest accepted share winning, the share_seq tie-break, case folding, rejected shares, missing shares and bare 64-digit IDs. A unit test pins the probe to 016's. 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. |
…e native path, and fix the statement count (#672) From /code-review high on #680: - The unit test reads the solver lookup from 016's landing trigger and requires the batch statement to make exactly that probe, rather than comparing the batch with a hand copy of itself. The trigger attributes every block landed after 016 and the batch the ones before it, so the two must not drift. - A native ledger without 16, with blocks and shares, applies 016 on the native path with the same attribution as the old single statement. - Every statement is counted, the final empty one too, so the logged count agrees with the slowest-statement figure: 107 for 13,566 blocks. - 016's header comment points to the note after the landing trigger, and the docs no longer say the file itself backfills the columns. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member
Author
|
|
RobertClarke
added a commit
that referenced
this pull request
Oct 5, 2026
Brings in #674 and #680; neither adds a migration, so 023 keeps its number. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 5, 2026
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 #672.
Migration 016 fills
qbit_pool_blocks.solver_*for the blocks a 2.x.x pool found before it. The lookup is one probe ofqbit_share_ledger_accepted_block_suffix_idxper block (13,566 on mainnet), exactly what the dashboard queries made on every request. 016's file ran it as oneUPDATE ... CROSS JOIN LATERALstatement inside the migration transaction, underPRISM_DATABASE_STATEMENT_TIMEOUT_MS. Each probe is two random reads (an index leaf and a heap page), so on a cold cache that single statement grows with the ledger. #582's measured rehearsal on a saturated disk saw it refused at the 15 s default.Change
UPDATE: columns, landing trigger, catalog and functions.block_hashand skip blocks that already have a solver (ledger/migration/block_solvers.rs).Measurements
Setup:
fsync,full_page_writesandsynchronous_commiton).CREATE DATABASE ... TEMPLATEcopy of the restored dump and a cluster restart.posix_fadvise DONTNEED).migrateran up to its commit, with the online runners held. Statement durations come fromlog_min_duration_statement.With a concurrent direct-I/O writer saturating the same disk (cold, 8.25M, at the default 15 s timeout):
Before: 016's statement took 14.0 s, one second short of the refusal; the transaction took 19.0 s.
After: the longest statement took 0.47 s (107 statements, 11.9 s total); the transaction took 14.4 s.
Before: the single statement's cold time grows with the ledger: 6.7 s at 8.25M, 11.2 s at 16.5M, from a quiet disk. At mainnet's 65.5M it would pass the 15 s default even without contention.
After: the longest statement is under 0.6 s in every run, against 15 s, and doesn't depend on the ledger's size.
Totals stay in the same range: the same probes are made. The 8.25M warm run's 9.1 s was host noise; the cold run of the same data took 3.9 s.
So
migrateno longer needs the 60000 ms fallback 3.x.x: bound 016's solver attribution per statement, so migrate's transaction stays inside the default statement timeout on a cold cache #672 and 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's notes gave for 016.Tests
ledger_postgres::block_solvers::migration_016_attributes_a_2x_sources_blocks_as_its_single_statement_did, on a frozen 2.x.x source with 300 blocks (three statements' worth), in six cases:share_seqwins;The attribution must equal the old single statement's lookup, row for row, and every version must be recorded.
ledger_postgres::block_solvers::migration_016_attributes_a_native_ledgers_blocks_when_016_is_missing: the same attribution on the native path, for a native ledger without 16.Unit: the batch makes exactly the lookup 016's landing trigger makes (read from the file), and keysets by
block_hash.ledger_postgres(the whole binary),share_partitions_postgresandmigration_rollback's PR rehearsal: see the test run on this PR.Docs
docs/prism-rust-migration.md's 016 section gives the cost model, the before table, and what the migrator does now. 016's file says where its backfill went.🤖 Generated with Claude Code