Skip to content

DO NOT MERGE without coordinator GO: 3.1 pre-migrate: rc.6 serves while 3.1's migrate applies 027, 028 and 031, and p0 is never rewritten - #773

Merged
RobertClarke merged 3 commits into
3.x.xfrom
RobertClarke/p31-rc7-compat
Oct 19, 2026
Merged

RobertClarke merged 3 commits into
3.x.xfrom
RobertClarke/p31-rc7-compat

Conversation

@RobertClarke

@RobertClarke RobertClarke commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Base 3.x.x (the 3.1 stack, #763 squash-merged as f11b817). Tests and CI only: no product code changes.

Why

The 3.0 → 3.1 cutover can apply 3.1's migrations to A's database before its window, while the 3.0 pair keeps serving on 3.0.0-rc.6. The window's migrate step then becomes a read-back, and 031's index build (long on a large ledger) moves out of the outage. This PR proves rc.6 frontends accept a database 3.1's migrate takes to 27, 28 and 31, and keep serving throughout. It also proves the online 031 build never rewrites, freezes, vacuums or analyzes the ledger's data partition, p0 (qbit-tools #1345).

Why rc.6 accepts it. The pair serves v3.0.0-rc.6 (81c592c3) until the 3.1 repin (rc.7 was skipped). rc.6's start gate is require_schema_version in crates/qbit-prism-server/src/ledger/migration.rs at 81c592c3. It refuses only a database missing one of the migrations it requires (2 to 26), and logs any migration it doesn't know: "database has schema migrations this server does not know; a later release applied them". 027, 028 and 031 declare no capability, so rc.6's connect-time capability gate (require_known_capabilities) passes too. Production lanes render PRISM_POSTGRES_INIT_SCHEMA=0, so an rc.6 frontend never migrates.

What runs

Both tests are new ids in the dual-writer fast lane and the nightly matrix, and are named in test/e2e-scenarios.toml.

R1 (r01_rc6_pair_serves_lands_and_restarts_while_3_1_migrates_its_database_to_31)

The 3.0 pair (A the writer, B its streaming standby, both frontends writing A's database) runs on rc.6 under load. rc.6's own migrate made the database, and every start runs with PRISM_POSTGRES_INIT_SCHEMA=0.

  1. A lands a block at schema 26.
  2. 3.1's migrate runs once, as a one-off command with A's frontend environment (its writer role and DSN). A reader holds a snapshot from before it, as any long read on the primary can, so 031's first CREATE INDEX CONCURRENTLY waits part-way.
  3. Checked while it runs:
    • 027 and 028 commit with every share sent meanwhile answered, none refused (shares on superseded work are counted separately) and none waiting the frontends' 5 s lock timeout.
    • Appends continue during the build, and A lands a block.
    • A's frontend restarts and serves with 31 unrecorded and the index invalid, warning of 27 and 28.
  4. Checked once the reader ends:
    • migrate reports …, 26, 27, 28, 31 ready.
    • The origin index is valid on the writer and, by replication, on the standby.
    • B's frontend restarts and serves at 31, warning of 27, 28 and 31.
    • A lands a last block. rc.6's landings and jobs after 027 take its defaults (node 0, a sync_seq from qbit_prism_next_sync_seq(), which rc.6's role may call).
    • No frontend statement is cancelled, and every checker invariant passes.

p0 (r01_the_premigrate_never_rewrites_freezes_vacuums_or_analyzes_the_ledgers_data_partition, src/premigrate.rs)

This test runs no frontend. It uses one PostgreSQL 16 cluster with log_min_duration_statement = 0 and autovacuum off, so any change is the migrate's.

  1. rc.6 migrates the database.
  2. 300,000 synthetic rows (about 450 bytes each) fill p0, and 690 audit snapshots are added. Setup vacuums p0 once, before any baseline is read.
  3. An appender appends as a frontend does (mapping read, ledger row, mapping) under lock_timeout = 5s while 3.1's migrate runs.

Checked:

  • p0 and its TOAST table keep their relfilenode, relfrozenxid and relminmxid, and so does every other partition.
  • Their vacuum and analyze counters are unchanged.
  • The statement log holds no VACUUM, ANALYZE, CLUSTER or REINDEX command.
  • p0's only index build is CREATE INDEX CONCURRENTLY.
  • Every append succeeds within the lock timeout.

The test also reports, from the statement log:

  • the 027+028 transaction's holds: the ledger's lock from 027's last step to the commit, and the copied tables' locks from 027's start;
  • the 031 build on p0, the parent ON ONLY and each attach;
  • temp-file bytes and the index size.

A by-hand variant (r01_measure_the_premigrate_on_a_ledger_of_millions_of_rows, no lane) runs the same at scale. It is configured by PRISM_PREMIGRATE_ROWS, PRISM_PREMIGRATE_MWM and PRISM_PREMIGRATE_WORKERS.

Not covered: what PostgreSQL itself does. CIC and autovacuum both take SHARE UPDATE EXCLUSIVE on p0. A build waits for a vacuum already running there (an anti-wraparound one is not cancelled for it), and no autovacuum of p0 starts during the build. Each CIC phase also holds a snapshot, which holds back dead-row cleanup database-wide for the build.

Local results (this host)

  • R1 passes in 35 s. 027 and 028 committed 0.8 s after the migrate started (that span includes the migrator's scratch apply, which locks no live table). No share was refused, the longest answer was 70 ms, and both rc.6 restarts were ready in 1.2 to 1.4 s.
  • At 300,000 rows the ledger's lock is held about 4 ms and the copied tables' about 28 ms. p0's CIC took 125 ms; the parent and each attach took about 1 ms. The longest append was 12 ms.

Wiring

  • qbit-prism-test-gate gains PRISM_TEST_RC6_SERVER_BIN (Input::Rc6ServerBin), and check_gate_env_reads.py gains the name.
  • The .github/actions/prism-rc6-server action builds qbit-prism-server from the v3.0.0-rc.6 commit (81c592c3), checks --version, caches it per commit, and exports the path. Both the fast lane and the nightly job use it.
  • dual-sim: SimConfig::frontend_release (This or Rc6) and Inputs::rc6_server.

Review notes

  • A local /code-review medium raised P2s, and I fixed most of them in 0a01c6f:
    • every index build on p0 is now detected, including unnamed ones and recursive parent builds, and the scratch apply is excluded;
    • p0's TOAST counters are compared too;
    • timestamps work across midnight;
    • the seed must fit in p0;
    • R1's restarts must be graceful and wait for the balancer;
    • the spawned migrate is aborted when a step fails.
  • Two P2s are deferred:
    • the p0 test writes outcome.json, not a matrix report.json, but its gate-manifest line still proves it ran;
    • consolidating the env-stripping helper is a style point.
  • rc.6 and rc.7 compared: at 81c592c3 and 4c134913, require_schema_version, NATIVE_CAPABILITIES, require_known_capabilities, refuse_unknown_capabilities, require_declared_capabilities and the migration SQL are identical. The migration.rs diff between them is 3.x.x: import-audits holds SETTLEMENT_LOCK while writing a large canonical audit body (≥90 s for ~112 MB), stalling template refresh and settlement #765's import code in impl Ledger.
  • Operational finding: with a disk-saturating job running beside the migrate, frontends hit their 5 s lock timeouts from fsync starvation. The qbit-tools runbook (SwapLabsInc/qbit-tools#1362) therefore forbids overlapping the pre-migrate with heavy disk jobs.

🤖 Generated with Claude Code

@blacksmith-sh

blacksmith-sh Bot commented Oct 19, 2026

Copy link
Copy Markdown

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
tests.test_ckpool_rejects_observability.CkpoolRejectsObservabilityTests.test_reason_tax
onomy_block_outcomes_and_atomic_writer/
test_reason_taxonomy_block_outcomes_and_atomic_writer
View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@RobertClarke
RobertClarke force-pushed the RobertClarke/p31-dual-writer-e2e branch from e479006 to 327e596 Compare October 19, 2026 20:16
@RobertClarke
RobertClarke changed the base branch from RobertClarke/p31-dual-writer-e2e to 3.x.x October 19, 2026 20:45
RobertClarke and others added 3 commits October 19, 2026 16:47
…028 and 031, and p0 is never rewritten

The 3.0 -> 3.1 cutover can run 3.1's migrate against A's database before
its window, while the 3.0 pair serves on 3.0.0-rc.7. Two gated dual-sim
tests hold that to what the cutover relies on, in the fast lane and the
nightly matrix:

- R1: the 3.0 pair on rc.7 under load (database made by rc.7's migrate,
  every start with PRISM_POSTGRES_INIT_SCHEMA=0). 3.1's migrate runs once
  with A's frontend environment while a reader holds a snapshot, so 031's
  CREATE INDEX CONCURRENTLY is caught part-way. 027 and 028 commit with no
  share refused and none waiting the 5 s lock timeout, appends continue, a
  block lands, A restarts and serves with 31 unrecorded and the index
  invalid, then 31 is recorded, the index is valid on the writer and the
  standby, B restarts at 31, a last block lands, and the checker's
  invariants hold.
- p0: on a populated ledger with an appender under the frontends' lock
  timeout, p0 and its TOAST table keep relfilenode, relfrozenxid and
  relminmxid and their vacuum and analyze counters, the statement log holds
  no VACUUM, ANALYZE, CLUSTER or REINDEX, and p0's only index build is
  CREATE INDEX CONCURRENTLY (qbit-tools #1345).

A by-hand measurement runs the second at millions of rows. The gate gains
PRISM_TEST_RC7_SERVER_BIN, and the prism-rc7-server action builds the
pinned rc.7 commit (#772's head b7b6923) once per pin.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… restarts

From a local review of #773:
- An index build on p0 is any CREATE INDEX on it, named or not, or on the
  ledger without ONLY (which recurses into every partition); the scratch
  apply's statements, under the migrator's rolled-back savepoint, are left
  out, and maintenance commands are counted everywhere.
- p0's TOAST table's vacuum and analyze counters are compared too
  (pg_stat_all_tables), and log timestamps are compared by date and time,
  so a run across midnight measures right.
- The seed is refused unless every row stays in p0.
- R1's restarts wait for the balancer to mark the node down before starting
  it, require a graceful stop, and count shares from when the balancer had
  the node up again; the one-off migrate and the appender are aborted, and
  the migrate killed, when a step fails first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rc.7 was skipped: the pair serves v3.0.0-rc.6 (81c592c) until the 3.1
repin, so the pre-migrate runs beside rc.6 frontends, and R1 and the p0
test run rc.6 (PRISM_TEST_RC6_SERVER_BIN, the prism-rc6-server action at the
v3.0.0-rc.6 commit). rc.6's start gate, require_schema_version, its
NATIVE_CAPABILITIES and its connect-time capability checks are identical to
rc.7's (4c13491), as are the migration files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@RobertClarke
RobertClarke force-pushed the RobertClarke/p31-rc7-compat branch from 38e8f83 to 1efe2f0 Compare October 19, 2026 20:47
@RobertClarke RobertClarke changed the title DO NOT MERGE without coordinator GO: 3.1 pre-migrate: rc.7 serves while 3.1's migrate applies 027, 028 and 031, and p0 is never rewritten DO NOT MERGE without coordinator GO: 3.1 pre-migrate: rc.6 serves while 3.1's migrate applies 027, 028 and 031, and p0 is never rewritten Oct 19, 2026
@RobertClarke
RobertClarke marked this pull request as ready for review October 19, 2026 20:47
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T20:54:38.079169Z 1efe2f0 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@RobertClarke

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 1efe2f0b73

ℹ️ 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".

@RobertClarke

Copy link
Copy Markdown
Member Author

CI note on 1efe2f0: one unrelated failure, needs gh run rerun 39322302257 --failed

Shard 3 failed in readiness_frontend::an_admitted_dual_writer_frontend_withdraws_within_seconds_of_its_database_hanging. The other two red checks ("Prove every Rust PRISM gated test executed" and "Lint, compile, and test") only aggregate that shard.

  • DO NOT MERGE without coordinator GO: 3.1 pre-migrate: rc.6 serves while 3.1's migrate applies 027, 028 and 031, and p0 is never rewritten #773 does not touch it. It changes nothing under crates/qbit-prism-server (the diff against 3.x.x is limited to crates/qbit-prism-dual-sim, the test gate, CI wiring and test lists). 3.x.x passed this test at f11b817 (run 39321972487).
  • What happened. /readyz went 503 3.8 s after the database froze, and /healthz reported admission.state = withdrawn. The server logged PRISM withdrew … dual-writer Stratum listeners refusing new connections at 21:17:58.531Z, and the test's refused(ports.stratum) connect about 50 ms later was still accepted. That looks like a window between the withdrawal being reported and the listener actually refusing. It belongs to the readiness PR's test (or its listener close ordering), not to this PR.
  • Every other check passed, including the dual-writer fast lane, which runs R1 and the p0 test against rc.6. Codex found no issues on this head.

@RobertClarke
RobertClarke merged commit 4b1aefe into 3.x.x Oct 19, 2026
59 of 62 checks passed
RobertClarke added a commit that referenced this pull request Oct 19, 2026
RobertClarke added a commit that referenced this pull request Oct 19, 2026
RobertClarke added a commit that referenced this pull request Oct 20, 2026
* 3.x.x: version 3.1.0-rc.1

VERSION, the workspace version and both lockfiles move to 3.1.0-rc.1.
The fuzz lockfile also picks up hyper and hyper-util, which #769 added to
the server without refreshing it. The 3.0.0 and development-line notes
point at the new candidate; its own notes follow in this pull request.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* 3.x.x: 3.1.0-rc.1 release notes

The notes cover everything since v3.0.0-rc.6: #770's import-audits fix
(#765) and #760's idle-connection bound (#759), which would have shipped as
rc.7, and the 3.1 dual writer (#766, #768, #767, #769, #763), off by
default. They describe the new settings, migrations 027, 028 and 031 (029
and 030 reserved), the upgrade from rc.6 with the migrate run while rc.6
serves, the rollbacks, and the dual writer's known limits. The migration
guide's import-audits paragraph names this candidate in place of the
skipped rc.7.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* 3.x.x: 3.1.0-rc.1 notes: #773's pre-migrate tests

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* 3.x.x: 3.1.0-rc.1 notes: the rollback to one writer stops and syncs the peer first

Codex on #774: DOWNGRADE fences nothing, so the peer must be stopped, and its
tail pulled, before the single-writer start; declare the tail lost only for a
peer that never returns with its own database.

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 26, 2026
* 3.x.x: version 3.1.0, and tokio 1.53.3 for RUSTSEC-2026-0386

VERSION, the workspace version and both lockfiles' workspace members move
to 3.1.0. tokio moves from 1.53.1 to 1.53.3, its first fixed patch
release for RUSTSEC-2026-0386, in the root and fuzz lockfiles, as main
took it in #781. cargo update -p tokio --precise 1.53.3 also moved the
windows-sys edges of four unrelated crates to 0.52.0, so, as in #781,
only tokio's version and checksum change. Nothing in the workspace uses
AsyncFd.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* 3.x.x: 3.1.0 release notes, and 3.x.x as the production line

doc/release-notes-3.1.0.md covers the changes since 3.1.0-rc.1 (#777's
TLS updates and the tokio update), the upgrade from rc.1 (a binary swap)
and from 3.0.0 or 3.0.0-rc.6 (#773's pre-migrate, the binary, then the
optional dual-writer cutover), and the known issues carried from rc.1
plus #779's L3 failures and the acknowledgement bound's connection drop
that main fixes in #781. The README banner, the development-line note
and the migration guide now say 3.x.x is the production line, deployed
from the v3.1.0 tag.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* 3.x.x: 3.1.0 notes: review fixes

The migration guide and ledger operations cite the released 3.0.0 notes'
D5 boundary at v3.0.0, not this branch's pre-release copy. The
development-line note's header no longer calls the line "not a release".
The 3.1.0 notes say a dual-writer-off frontend serves as 3.0's does once
the migrations are applied, tell a 2.0.x upgrade that #765's guard is not
needed, and list the required prism-dual-writer lane and rc.1's evidence
set under Verification.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* 3.x.x: 3.1.0 notes: second review round

The #779 known issue counts the async preset's failed repeats (four of
six) and names the sync preset rather than a repeat's job. The cutover
step names node-identity repersonalise and defers the cutover itself to
the pair's runbook, as rc.1's notes do. Verification says docs changed
since rc.1 too. The development-line note says 3.0.x is not an ancestor
of 3.1.0, and the migration guide no longer implies the 3.0.0
candidates were a supported production upgrade.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* 3.x.x: 3.1.0 notes: rewrap two lines

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@RobertClarke
RobertClarke deleted the RobertClarke/p31-rc7-compat branch November 3, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant