Repository navigation
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) - #681
Conversation
…e 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]>
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: 3cb91f2fda
ℹ️ 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".
…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]>
|
CI on 3cb91f2 failed only in |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4f0f004a49
ℹ️ 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".
…sume, 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]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7671768cc7
ℹ️ 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".
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]>
…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]>
…aration (#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]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c20fdf29ca
ℹ️ 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".
… 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]>
…ence # Conflicts: # crates/qbit-prism-server/src/ledger/migration.rs # docs/prism-rust-migration.md # scripts/prism-recovery-evidence.sql
…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]>
… 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]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1d3843b74e
ℹ️ 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".
…t, 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]>
…ence # Conflicts: # docs/prism-rust-migration.md
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fixes #669.
#582 (#663) records migration 2 only after 002's share-hash backfill. Every start refuses the database until then, because every native build requires 2. The gap: an earlier build that meets "3 without 2" tells the operator to record 2 by hand once 002's objects exist. After that, the earlier build would serve with legacy headers unmapped and could credit a header twice. #663 only documented "never record 2 by hand".
Change: a pending-backfill capability, using the repo's capability mechanism
share_hash_backfill_pending = 1is in this build'sNATIVE_CAPABILITIESand in the evidence export's list of understood capabilities.Why only with a new cursor
An earlier build can't remove the fence, so the fence must never coexist with an earlier build's backfill runner. Such a runner would finish the backfill, drop the cursor and record 2, and the fence it doesn't know about would then refuse the database for good.
migratepasses its capability check once the fence has committed.The price: a backfill that a #582 build started before #669 stays unfenced until it finishes. The guide and the release note say so: resume it with this release, and don't record 2 by hand.
What it enforces, for a fenced backfill
require_known_capabilities) and at migrate (refuse_newer_native_database) while the fence is declared, whatever the migration record says.migraterefuses it before any DDL, naming that cause instead of the "3 without 2, record it by hand" remedy.scripts/prism-recovery-evidence.sql.migratestill answers 3-without-2 with its "record 2" remedy, which changes nothing, because its nextmigraterefuses the capability;Tests
Unit:
NATIVE_CAPABILITIESwithout the new entry, refuses the fence, and this build's accepts it;NATIVE_CAPABILITIES.Integration (
ledger_postgres::share_hash_backfill, all registered intest/prism-gated-tests.txt):migration_002_fences_earlier_builds_until_its_backfill_is_recorded:a_resume_leaves_no_fence_when_an_earlier_runner_finishes_the_backfill:a_crashed_resume_leaves_no_fence_for_an_earlier_runner_to_strand:migrateand a start succeed.migration_002_refuses_a_backfill_fence_left_without_its_cursor:migraterefuses the fence before any DDL and changes nothing;migratestill refuses, and a start finds 13, 17 and 24 missing;migraterefuses the value as newer.a_runner_leaves_a_newer_releases_fence_with_its_cursor_and_record:migraterefuses the value as newer, and a start still refuses the pending backfill.every_start_refuses_a_backfill_fence_on_a_migrated_database:migrate;Also:
migration_rollback's metadata regression: the evidence export refuses a fence without its cursor.live_regtest(which needs qbitd) and the lib tests pass locally: 1931 tests, 0 failures.Docs
docs/prism-rust-migration.md, the backfill section:doc/release-notes-3.x.x-development-line.md: the 3.x.x: migration 002's share-hash backfill cannot complete on a production-sized ledger (statement timeout) #582 entry describes the fence and the backfills it doesn't cover.🤖 Generated with Claude Code