Repository navigation
test(migrations): prepare for freezing migrations 1-12 in v0.1.15 - #1068
Conversation
The release that freezes catalog migrations 1 to 12 raises RELEASED_THROUGH from 0 to 12, and Runner::forget then refuses every id from 1 to 12. Ten tests and two devtools scripts forget one of those ids and expect success, and two extenddb-storage unit tests assume no id is released. Each now passes with the bound at 0 and at 12. Where forget only made a migration pending again, the test deletes the migration's ledger row with the backend's own client (the version row is left as it was; the next run rewrites it): - migration 6's backfill tests on SQLite, PostgreSQL and Cassandra; - the PostgreSQL re-registration on a changed status; - the Cassandra check that the status before the lock reads no policy; - the backup commands' exit 3 on a catalog behind the binary (tests/test_backup_store_config.py). Where the test is about forget, it keeps its purpose with a runner given a released bound of 0: PostgreSQL's forget-and-reapply test, MongoDB's, SQLite's in changed_ahead_and_forgotten_ledgers, SQLite's one-transaction test, and the "nothing to forget" case of forget_refuses_an_id_it_cannot_forget. Runner::with_released_through is exposed under the existing test-util feature for this, and SQLite's forget takes the runner through a new forget_with. Release builds do not enable test-util, and nothing a release binary reads can change the bound. each_refusal_names_its_command checks the Changed advice on both sides of the bound: --forget for RELEASED_THROUGH + 1, and "run the ExtendDB release that recorded it" for RELEASED_THROUGH. The PostgreSQL and Cassandra catalog lock scripts ran `migrate --forget <id>` and expected exit 0. They now check that `--forget` of an id the binary does not carry exits 1 and leaves the lock free, delete the migration's ledger row themselves, and check that `migrate --yes` applies it again, as before. Since every forget test sets its own bound, none checked the bound a release binary uses: Runner::new could set 0 and every test would pass. the_default_runner_refuses_every_id_this_binary_released checks that Runner::new refuses each id from 1 to RELEASED_THROUGH with "has been released" and forgets the first id above the bound, so it holds at any bound. devtools/check-postgres-catalog-lock reads the bound from registry.rs and, when it is above 0, checks that the binary's `migrate --forget 1` exits 1 with that message and leaves both ledgers unchanged. Signed-off-by: Scott Robinson <robinnsc@amazon.com>
The docs, the messages the binary prints and the comments beside them were written for the migration ledger arriving in 1.0. It arrives in 0.1.15, which is itself a 0.1.x release and a release before 1.0, so "a release before 1.0", "a 0.1.x release" and "the v1.0 schema" would include the release that brings the ledger. Statements about which releases predate the ledger, the frozen migrations or the 14-digit backup ids now name 0.1.14 and earlier, or 0.1.15 and later. Migration 1's schema is called that instead of the v1.0 schema. The printed messages that change: - "a release before 1.0" becomes "a release before 0.1.15" in the status, the migrate advice and preview, and --reconverge's help; - migrate-legacy's refusal and its --help name "the 13-digit shape that 0.1.14 and earlier releases issued"; - PostgreSQL's and Cassandra's check after migration 1 compare with migration 1's schema; - migration 1's description in migrate --list drops "v1.0". The tests and devtools scripts that match these messages change with them. The CI steps that run the 0.1.14 images are named for 0.1.14. README.md and docs/cassandra-setup.md say the Cassandra image is published from 0.1.15. docs/versioning.md stated its rules for every release: a patch release adds no configuration key and no breaking catalog migration, and rolls back with the earlier binary. 0.1.15 does both, and rolling it back needs the backup taken before the upgrade. The page now says the rules apply from 1.0 and what a 0.x release can change, and that the crates are published to crates.io from 0.1.15. The upgrade manual gains a 0.1.15 entry for #511: a Query whose partition key condition is not an equality now gets AccessDeniedException where a LeadingKeys fence does not cover its operand, where 0.1.14 answered ValidationException. The six 0.1.15 entries whose headings named no release (#515, #384, #471, #692, #581, note says one server per catalog "in this release", as README.md does. CONTRIBUTING step 7 lists Cassandra's checksum test, and differences-from-dynamodb.md no longer says "this branch". Statements about 1.0 as a milestone (scope, support policy) are unchanged. So are the migration bodies, whose checksums the release freezes, the ADRs, which are not edited after acceptance, the design document's revision log, and the RELEASED_THROUGH and RELEASED comments that the release commit rewrites. Signed-off-by: Scott Robinson <robinnsc@amazon.com>
The Cassandra image's Docker Hub overview said every image is signed with the KMS release key and showed `cosign verify --key`. release-image.yml signs every backend's image keyless through .github/actions/sign-image, and the first Cassandra image is published after the keyless migration, so no Cassandra image carries a key signature. The overview now gives the keyless verify command and signer identities that the PostgreSQL and MongoDB overviews give. devtools/release-dry-run's SHA-256 record step ran `cd target/package`, which fails when CARGO_TARGET_DIR (or a cargo config) moves the target directory, as `cargo package` then writes elsewhere. The step now reads target_directory from `cargo metadata`, as devtools/check-crate-packages does. release-crates.yml runs with the default target directory and is not affected. Signed-off-by: Scott Robinson <robinnsc@amazon.com>
LeeroyHannigan
left a comment
There was a problem hiding this comment.
Nothing here blocks the release. Points outside the diff:
- The migration 1 bodies still say "v1.0" and "releases before 1.0":
crates/storage-sqlite/migrations/0001_baseline.sql:4,129,435,crates/storage-postgres/migrations/0001_baseline.sql:6,93,398,399,crates/storage-postgres/data_migrations/0001_baseline.sql:6,116,crates/storage-cassandra/migrations/catalog/0001_baseline.cql:6,24,347,348,crates/storage-cassandra/migrations/account/0001_baseline.cql:6,17,crates/storage-mongodb/src/migrations/m0001_baseline.rs:4,15,17,119andcrates/storage-sqlite/src/migrations/m0001_baseline.rs:4. The two.rsmodules can be reworded before #1069 at no cost, since a ledger records their fingerprint. The SQL and CQL files record their own checksum: a reword before #1069 makes catalogs built from main reportChangedfor migration 1, and a reword after #1069 needs areblessentry. If they stay as written, a line in the description would record that. - Four entries under "Behavior Changes by Release" shipped in v0.1.14 and carry no label: lines 833, 947, 964 and 994, from #419 and #420 (
git tag --containsgives v0.1.14 for both). Next to thev0.1.15:labels they read as unreleased.v0.1.14:on the four headings fixes that. docs/design/15-backup-restore.md:620still says "the 13-digit shape every 0.1.x backup has".
|
|
||
| ## What a release can change | ||
|
|
||
| These rules apply from 1.0. A 0.x release, 0.1.15 among them, can add configuration keys, CLI flags and backup format versions, can carry breaking catalog migrations, and can raise the minimum Rust version, whatever part of its number changes. 0.1.15 adds configuration keys and breaking catalog migrations, so a rollback from it to 0.1.14 needs the backup taken before the upgrade, not only the 0.1.14 binary (see the [Rollback Procedure](manuals/07-upgrade-manual.md#rollback-procedure)). |
There was a problem hiding this comment.
Line 40 still says "Every migration in 1.0 is breaking." With this paragraph, migrations 1 to 12 ship in 0.1.15, and #1069 freezes several of them as additive or not applicable on some backends (see the comment on line 77 of the upgrade manual). Suggest for line 40: "Migration 1 is breaking on every backend. extenddb migrate --list prints the kind of each migration on the configured backend."
ADR-0023 says 1.0 for the release that brings the ledger on lines 14, 155, 159, 202, 275, 290, 340 and 369 to 389. It is a record, so a dated note at its top that the ledger shipped in 0.1.15 would cover them.
| `verify` also checks the connection to the data database. When that check fails, `verify` exits 1 on a Behind catalog instead of 3, because `migrate --yes` cannot apply the pending migrations while the data database cannot be reached. It still exits 4 or 5 for the statuses that need a person. | ||
|
|
||
| A migration is additive when the previous release serves the catalog correctly with it applied, and breaking otherwise. Migrations 1 to 7 and 9 to 12 are breaking. Migration 8 creates a table in the PostgreSQL data database that the previous release never reads; on PostgreSQL it is declared breaking only because the job that proves an additive declaration against the old binary does not yet exist (CONTRIBUTING, step 4 of adding a migration), and on SQLite, MongoDB and Cassandra it does not apply (`migrate --list` prints it as not applicable, and `migrate` counts it as additive). Do not run a 0.1.x server against a migrated catalog. A 0.1.x binary that writes to a migrated catalog (its `migrate --yes`, or a SQLite dev server) leaves it WrittenByOlderRelease. `migrate --yes --reconverge` repairs it by running the convergent migrations again. Migration 2, which rewrites stored policies, is not convergent: the repair skips it and prints a line that says so (see the v0.1.14 notes below). | ||
| A migration is additive when the previous release serves the catalog correctly with it applied, and breaking otherwise. Migrations 1 to 7 and 9 to 12 are breaking. Migration 8 creates a table in the PostgreSQL data database that the previous release never reads; on PostgreSQL it is declared breaking only because the job that proves an additive declaration against the old binary does not yet exist (CONTRIBUTING, step 4 of adding a migration), and on SQLite, MongoDB and Cassandra it does not apply (`migrate --list` prints it as not applicable, and `migrate` counts it as additive). Do not run a server of 0.1.14 or an earlier release against a migrated catalog. A binary of those releases that writes to a migrated catalog (its `migrate --yes`, or a SQLite dev server) leaves it WrittenByOlderRelease. `migrate --yes --reconverge` repairs it by running the convergent migrations again. Migration 2, which rewrites stored policies, is not convergent: the repair skips it and prints a line that says so (see the v0.1.14 notes below). |
There was a problem hiding this comment.
This sentence and line 215 ("every migration in this release is breaking") disagree with the kinds #1069 freezes. Migration 12 is not applicable on PostgreSQL, SQLite and Cassandra, and migrate records it as additive. A release build of #1069 prints it in migrate --list on PostgreSQL as not applicable: access_key_id is the primary key of access_keys, so an ID can be stored once. The RELEASED tables also declare SQLite 7, 8 and 11, MongoDB 3, 4, 7, 8, 9 and 11, and Cassandra 3, 4, 7, 8 and 11 additive.
The rollback steps stay right because migration 1 is breaking on every backend. Both lines can say that and point at migrate --list for the kind of each migration.
| /// `forget` deletes the ledger row and writes the version row in one | ||
| /// transaction: when the version row cannot be written, the ledger row is | ||
| /// still there. | ||
| /// still there. The command's path is followed under the lock, with a |
There was a problem hiding this comment.
The test now calls forget_with on its own SqliteMigrations, so SqliteCatalogMigrations::forget (commands.rs:127) does not run, and "the command's path is followed" no longer holds. This test and storage-cassandra/tests/migrations.rs:517 were the two Rust tests that called a backend's CatalogMigrations::forget, and with this PR none does. The SQLite and MongoDB lock scripts never run --forget, so those two entry points run in no test at the release bound.
Suggest also calling SqliteCatalogMigrations.forget(&lock, 1) under the lock, and asserting the has been released refusal and an unchanged ledger. Otherwise the comment can drop the command path.
| return False | ||
|
|
||
|
|
||
| def released_through() -> int: |
There was a problem hiding this comment.
released_through() repeats the parser of devtools/check-released-through: the same regex on the same file. This script already imports catalog_checks, so the function could live there for both.
The step at line 201 also puts the bound in the expected text, so it passes only when the checkout's bound equals the binary's. Run from a tree at bound 13 against this 0.1.15 binary, it fails a correct binary. Matching only migrations above \d+ can be forgotten checks the refusal whatever bound the checkout has.
…icy text Main renamed the release that brings the migration ledger from 1.0 to 0.1.15 in its messages and docs (#1068). The text that this branch adds still used the old names. The progress line that serve prints for a catalog with no ledger now says "a release before 0.1.15", as the status and migrate messages do. The upgrade manual's section on migrations at startup now names 0.1.15, or 0.1.14 and earlier releases, instead of 1.0 and 0.1.x. The Helm note in the deployment guide and a Cassandra test comment change in the same way. The note about one server per catalog says "this release", as the other notes on main do.
What
Prepares main for the v0.1.15 release PR, #1069, which freezes catalog migrations 1 to 12. Merge this one first; #1069 is stacked on it.
Background. Each catalog store keeps a migration ledger: one row per applied migration, with the checksum of the code that ran.
RELEASED_THROUGHincrates/storage/src/migrations/registry.rsmarks which migrations have shipped. Those are frozen: their checksums are pinned, andextenddb migrate --forget <id>, which deletes a ledger row so the migration runs again, refuses them. #1069 raisesRELEASED_THROUGHfrom 0 to 12, which breaks the tests and text below.1. Tests that forget a frozen migration
Ten tests and two devtools scripts called
forgeton an id from 1 to 12 and expected it to succeed.forgetonly made a migration pending again, the test now deletes the ledger row with the backend's own client.forgetitself, it uses a runner with a test-only bound of 0 (Runner::with_released_through, now exposed under the existingtest-utilfeature). Release builds don't enabletest-util, and nothing at runtime can change the bound.extenddb-storageunit tests that assumed nothing was released now hold at either bound.the_default_runner_refuses_every_id_this_binary_releasedand a step indevtools/check-postgres-catalog-lockcheck that the shipped binary refuses--forgetfor every frozen id.2. Text that says the ledger arrives in 1.0
About 55 files said the ledger arrives "in v1.0" or called older releases "0.1.x" or "before 1.0". They now say 0.1.15 and later, or 0.1.14 and earlier. Statements about 1.0 as a product milestone are unchanged.
Printed messages that change wording:
migratestatus, advice and--reconvergehelp.backup migrate-legacyrefuses "the 13-digit shape that 0.1.14 and earlier releases issued".Other documents:
docs/versioning.md: the patch-release rules now apply from 1.0. 0.x releases, 0.1.15 included, can add configuration keys and breaking migrations. Crates are published from 0.1.15.v0.1.15:label.CONTRIBUTING.md: adds Cassandra's checksum test command.3. Release-path fixes
docker/dockerhub-overview-cassandra.mddescribed KMS-key signing, but the release workflow signs keyless. The page now matches the PostgreSQL and MongoDB pages.devtools/release-dry-run: the SHA-256 step failed whenCARGO_TARGET_DIRwas set.No product behavior changes apart from the reworded messages.
Testing done
Each check ran with
RELEASED_THROUGHat 0 (this PR) and at 12 (#1069's freeze applied, then reverted).cargo fmt --checkandcargo +1.97.0 clippy --workspace --all-targets -- -D warnings, with and without the storage test hooks: clean.cargo test -p extenddb-storage --lib: 265 passed at both bounds.check-postgres-catalog-lock(direct and through PgBouncer) andcheck-cassandra-catalog-lock: pass at both bounds.Runner::newhard-coded to a bound of 0 and the release bound at 12, the new unit test and the lock-script step both fail.Checklist
cargo test --workspace): not run in full; the affected suites above pass at both bounds, and CI runs the workspacecargo fmt --check)cargo clippy -- -W clippy::pedantic): checked as CI runs it,cargo +1.97.0 clippy --workspace --all-targets -- -D warningsStoragetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
ADR / RFC: ADR-0023 (catalog migrations).
Breaking changes
None. The printed messages change wording only; exit codes are unchanged.
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.