Skip to content

feat: store and report WarmThroughput on tables and global secondary indexes - #474

Merged
LeeroyHannigan merged 21 commits into
mainfrom
fix/462-warm-throughput
Nov 9, 2026
Merged

LeeroyHannigan merged 21 commits into
mainfrom
fix/462-warm-throughput

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

What

ExtendDB now stores and reports WarmThroughput on tables and global secondary indexes (GSIs), on all four backends. The shape, defaults, lifecycle and validation follow measurements on Amazon DynamoDB.

Nothing acts on the values. There is no pre-warming and no scaling at the database level, and the stored numbers have no effect on throughput, throttling or storage. They exist so clients that read the member work. docs/differences-from-dynamodb.md (Capacity and Throttling), docs/getting-started.md and the comment on the storage field state this.

Every rule below was measured on live DynamoDB (us-east-1, 2026-10-23 and 2026-11-03) before it was written. The raw observations are in the docstrings of the dual-target wire tests, as row ids.

Shape Service, now matched
CreateTable without the member absent while CREATING; once ACTIVE {12000, 4000, ACTIVE} on an on-demand table and its GSIs, the provisioned units on a provisioned table and its GSIs; LSIs carry none
CreateTable with the member echoed as sent with Status: UPDATING while CREATING; filled once ACTIVE (a read-only {20000} becomes {20000, 4000})
UpdateTable changing it the previous values with UPDATING, then the new values ACTIVE; a decrease is validated against the reported values
A lower request inside the UPDATING window accepted, and the value settles at the higher change still in progress (12200/4200, then 12000/4000 50 ms later, settles at 12200/4200 on a table and on a GSI)
Below minimum, below provisioned units, decrease ValidationException with the service's sentence, naming table or index <name>
Switch to PAY_PER_REQUEST a stored value below the on-demand minimum is raised to it
Capacity change on a never-set provisioned table the reported default follows the new units
Companions beside a table-level WarmThroughput refused in the measured order: Server-Side Encryption, TableClass, DeletionProtection (each its own sentence), OnDemandThroughput (needs BillingMode), a GSI Delete, then BillingMode, ProvisionedThroughput, StreamSpecification or vector updates (WarmThroughput must be the only operation in the request); a GSI Update beside it is accepted
GlobalSecondaryIndexUpdates one action per element; one update per index; an index Update carrying WarmThroughput beside ProvisionedThroughput or OnDemandThroughput is refused in either billing mode (WarmThroughput must be the only operation in the request for index: <name>); on an on-demand table an index Update may only carry OnDemandThroughput or WarmThroughput; a Create with WarmThroughput reports it on the CREATING index
Restore from backup the restored table starts with the defaults; a GSI override carrying WarmThroughput is refused

ExtendDB returns to ACTIVE after control_plane_delay_seconds, where the service takes minutes. It does not enforce the account maximum (LimitExceededException on the service).

ExtendDB answers an index Update without WarmThroughput according to the billing mode that the table has after the request. Under PAY_PER_REQUEST, an Update that carries ProvisionedThroughput or nothing gets the service's on-demand sentence. An Update that carries only OnDemandThroughput, or any Update under PROVISIONED, gets "UpdateGlobalSecondaryIndex is not yet supported", as on main.

ImportTable reports the defaults for the imported table and its indexes.

Catalog migration 9 (warm_throughput) adds one nullable warm_throughput column to tables and indexes. The migration has a file body on PostgreSQL (migrations/0009_warm_throughput.sql) and Cassandra (migrations/catalog/0009_warm_throughput.cql), and a code body on SQLite (m0009_warm_throughput.rs). On MongoDB the record is a document field, and the ledger records migration 9 as not applicable.

Commit 663c5a3 merges main (at 0cfb0d9) into this branch. Main now has catalog migrations 6 (backup_catalog_index), 7 (stream_pending) and 8 (restore_progress, which #740 added), so this migration is number 9. Before this merge it was number 8, in migrations/0008_warm_throughput.sql, migrations/catalog/0008_warm_throughput.cql and m0008_warm_throughput.rs. Before the first merge of main (a1badc3) it was number 6, in migrations/0006_warm_throughput.sql, migrations/catalog/0006_warm_throughput.cql and m0006_warm_throughput.rs.

Each backend stores one JSON record. TableDescription::prepare_for_response derives the wire member in one place, on every response path. ExtendDB logs a stored record that does not parse and reads it as never set, so it reports the defaults.

Concurrent UpdateTables that set different sides both keep their side:

  • MongoDB filters the write on the record that it read, and retries.
  • Cassandra writes the record through lightweight transactions (LWTs) conditional on the record that it read, and retries.
  • SQLite and PostgreSQL merge inside the catalog transaction.

UpdateTableInput now reads SSESpecification, so ExtendDB can refuse the member instead of silently dropping it. UpdateGsiAction now reads ProvisionedThroughput and OnDemandThroughput, so ExtendDB refuses an index Update that carries either member instead of dropping the member.

The backup manifest records the source table's indexes as BackupGsi and BackupLsi. These are the manifest's own types. They keep the members, names and serialization of the request types as frozen in format version 1. So GsiInput's new member does not change the format.

This PR does not change these differences from the service. They were measured on main during the work on this issue and filed separately:

  • When WarmThroughput is absent, the service has per-member "must be the only operation" rules for TableClass, DeletionProtection and Server-Side Encryption. ExtendDB accepts those pairs.
  • A GSI reports IndexStatus: ACTIVE while its table is CREATING.
  • The response to a capacity change has TableStatus: ACTIVE, where the service says UPDATING.
  • For UpdateTable with an empty WarmThroughput: {}, or an Update that names a missing index, the service answers its own InternalFailure.

Issue #771 covers ImportTable, which does not run CreateTable's validation. Issue #800 covers a Terraform apply that changes the tables.

Why

Since Terraform AWS provider 6.13.0 (September 2025), aws_dynamodb_table waits for WarmThroughput.Status to read ACTIVE after every table and index create or update. It also treats a DescribeTable without the member as not found. ExtendDB omitted the member, so every terraform apply against it polled until couldn't find resource (21 retries).

Issue hashicorp/terraform-provider-aws#44344 reports the same hang against DynamoDB Local. The provider team closed it as an emulator-side fix. The current provider is 6.70.0, and the only workaround was pinning 6.12.0.

Closes #462.

Testing done

  • Unit tests cover the record, the defaults and every rule (core, engine, storage, SQLite, MongoDB). They include the GSI Update members in either billing mode, the overlap rule, an unparseable stored record and the import.
  • The SQLite golden test on the 0.1.14 catalog and the migration suites of the four backends have 9 as the latest migration.
  • Three dual-target wire files under tests/python/ cover lifecycle and validation (12), update shapes and billing changes (13), and backup and restore (1). They pass against the service. On 64398e1 they passed in CI against SQLite, PostgreSQL, MongoDB and Cassandra. There, the skip from d8879f9 disabled S6c and S6d of tests/python/test_warm_throughput_backup.py on each server with a backup store. That skip is gone after this merge, so S6c and S6d run on every server. On a server with a backup store they restore through the restore job of feat(backup): RestoreTableFromBackup job and cross-backend matrix [backup/restore 9] #740, and CI on 663c5a3 is their first run there.
  • The update-shapes file also has an ExtendDB-only test. It sends two UpdateTables together, one per side, for ten rounds on a table and on a GSI.
  • tests/terraform/warm-throughput/ holds the configuration from the provider issue, plus a table with a GSI. CI applies it on every backend through devtools/run-tests --terraform, with Terraform 1.17.0 and provider 6.70.0. The test pins both, and asserts the checksum of the Terraform zip against the published sums. It asserts a clean apply and a second plan with no changes. Then it destroys the tables. --all does not run it, because it downloads Terraform and the provider and installs only linux_amd64.

Each of these negative controls makes a test fail:

  • With no member in the response, the Terraform apply fails with the provider's couldn't find resource (21 retries) after about three and a half minutes. This is the hang from the issue.
  • Without the validation, the refusal rows fail.
  • Five further built mutants (table member, index member, UPDATING deadline, only-operation rule, swapped defaults) each fail the wire file.

Every crate in the diff passes fmt and clippy 1.97 -D warnings, and passes on the minimum supported Rust version (MSRV), 1.88. The PR changes no dependency.

Checklist

  • I have read CONTRIBUTING.md
  • All tests pass (cargo test --workspace)
  • Code is formatted (cargo fmt --check)
  • Clippy is clean (cargo clippy -- -W clippy::pedantic)
  • I have added or updated tests for new functionality
  • I have updated documentation if behavior changed
  • Breaking changes are noted below (if any)
  • If this changes the wire protocol, Storage trait, auth model, on-disk
    format, 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. This change adds migration 9 under it.

Breaking changes

Migration 9 is Breaking and convergent. extenddb migrate --yes applies it. The upgrade manual describes it, and says that a downgrade to a release without it means restoring the backup taken before the upgrade.


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.

…indexes

Since Terraform AWS provider 6.13.0 the aws_dynamodb_table resource waits
for WarmThroughput.Status to read ACTIVE after every table and index
create or update and treats a description without the member as not
found, so an apply against ExtendDB polled until it timed out (#462).

ExtendDB now accepts WarmThroughput on CreateTable, UpdateTable and
GlobalSecondaryIndexUpdates (Create and Update), stores what the client
sent, and reports the member with the shape, defaults, lifecycle and
validation measured on Amazon DynamoDB on 2026-10-23:

* Absent while the table or index is CREATING unless the request named
  it (then echoed as sent with Status UPDATING); 12000 read and 4000
  write units on an on-demand table and its indexes, the provisioned
  units on a provisioned table and index; present with Status on every
  CreateTable, DescribeTable, UpdateTable and DeleteTable description.
* An update reports the previous values with Status UPDATING for the
  control plane delay, then the new values ACTIVE; a decrease is
  validated against the reported values. A switch to PAY_PER_REQUEST
  raises a stored value to the on-demand minimum. A capacity change on a
  never-set provisioned table moves the reported default with the units.
* Refusals carry the service's sentences: below the on-demand minimum,
  below the provisioned units, below the current value, each naming
  "table" or "index <name>"; one action per GlobalSecondaryIndexUpdate
  element; one update per index; on an on-demand table an index Update
  may only carry OnDemandThroughput or WarmThroughput.
* UpdateTable with a table-level WarmThroughput refuses companions in
  the measured order: Server-Side Encryption, TableClass,
  DeletionProtection (each with its own sentence), OnDemandThroughput
  (needs BillingMode), a GlobalSecondaryIndexUpdates Delete, then
  BillingMode, ProvisionedThroughput, StreamSpecification or vector index
  updates ("WarmThroughput must be the only operation in the request").
  GlobalSecondaryIndexUpdates Update beside it is accepted. A request
  carrying only WarmThroughput is accepted. SSESpecification is now read
  on UpdateTableInput so it can be refused rather than dropped.
* A restored table starts with the defaults; a GlobalSecondaryIndexOverride
  carrying WarmThroughput is refused with the service's sentence.

Nothing acts on the values. There is no pre-warming and no scaling at the
database level, and the stored numbers have no effect on throughput,
throttling or storage; they exist so clients that read the member work.
The account maximum the service enforces is not enforced here.

Storage: one nullable warm_throughput column on tables and indexes on
SQLite (schema plus shape convergence), PostgreSQL (001_schema.sql plus
shape steps for existing catalogs) and Cassandra (migration V006, catalog
version 0.0.5 so extenddb migrate applies it); a document field on
MongoDB. Each backend stores one JSON record (the client's sides, the
previous sides, and the UPDATING deadline); the wire member is derived
in one place, TableDescription::prepare_for_response.

On PostgreSQL, UpdateTable builds a new GSI before it answers (#401), which
takes longer than the 0.25 s UPDATING window the index row is inserted
with. The window of each GSI the request created with WarmThroughput
starts again once the build has run, so the response reports it UPDATING
as the service does.

Tests: unit tests for the record, defaults and every rule; three
dual-target wire files (lifecycle and validation, update shapes and
billing changes, backup and restore) covering every measured row; a
Terraform apply of the configuration from the provider issue plus a
table with a GSI on every backend, with Terraform 1.17.0 and provider
6.70.0 pinned and checksum-asserted in CI; a Cassandra test for a
catalog that has not run V006.

Measured on live DynamoDB: the three wire files pass against the service
(12, 13 and 1 tests) and against SQLite, PostgreSQL, MongoDB and
Cassandra. Cassandra lib (61) and direct_integration (151) suites pass.
Negative controls: with the member removed the Terraform apply fails
with the provider's "couldn't find resource (21 retries)" after about
three and a half minutes, which is the hang from the issue; with the
validation removed the three refusal rows fail; five further built
mutants (table member, index member, UPDATING deadline, only-operation
rule, swapped defaults) each fail the wire file.

Documented in docs/differences-from-dynamodb.md (Capacity and Throttling)
and docs/getting-started.md.

Closes #462.
@LeeroyHannigan
LeeroyHannigan force-pushed the fix/462-warm-throughput branch from 3b40060 to 0af920c Compare October 26, 2026 13:27
@LeeroyHannigan

LeeroyHannigan commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

Rebased on main at abf8082; conflicts in crates/storage-postgres/src/update_table.rs, crates/storage-sqlite/src/update_table.rs and crates/storage/src/util/mod.rs, resolved by keeping #401's GSI build flow (the new index is inserted CREATING) with this branch's warm_throughput column and bind, and both sides' imports and util exports.

The branch's commit also returned six files from #214 to their state before it: it deleted docs/rfcs/0003-backend-acceptance-criteria.md and removed the links to it from CONTRIBUTING.md, README.md, docs/design/04-component-storage.md, docs/rfcs/0002-backend-plugin-policy.md and docs/rfcs/README.md. Each of those files was byte-identical to its version before #214, and neither the commit message nor this PR mentions them, so they now match main and this PR no longer touches them.

On PostgreSQL, UpdateTable now builds the new GSI before it answers (#401), which takes longer than the 0.25 s UPDATING window, so test_gsi_create_with_warm_throughput_in_update_table failed with Status ACTIVE in the response. restart_created_gsi_warm_throughput in crates/storage-postgres/src/warm_throughput.rs starts that window again after the build. A DescribeTable during the build reads IndexStatus CREATING with WarmThroughput UPDATING; the response to UpdateTable then starts the window again, so the ACTIVE flip of the index and the UPDATING window of its WarmThroughput are observed in that order.

tests/python/test_warm_throughput*.py (26) and tests/test_gsi_online_backfill.py pass on PostgreSQL.

@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@robinnsc, this one needs your call on the backup format before I rebase it.

#474 adds WarmThroughput to GsiInput, and the v1 manifest uses GsiInput for the source table's GSIs, so nested_types_have_the_pinned_members fails on the rebased branch. The member has skip_serializing_if = "Option::is_none", and the byte-for-byte golden tests still pass, but the rule in manifest.rs makes any new member a version bump.

No release tag has #394 yet, so I see three ways: add WarmThroughput to the v1 pin with a fixture that carries it, give the manifest its own GSI type without it, or bump to v2 as the rule says. I'd go with the first while no release writes v1, but it's your rule. Which do you want?

@robinnsc

robinnsc commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Thanks for checking first. I'd go with the second option, a GSI type of the manifest's own, done in this PR as part of the rebase.

My reasoning is that WarmThroughput isn't something a backup should record. The service's own record of a backed-up index, GlobalSecondaryIndexInfo in DescribeBackup, has IndexName, KeySchema, Projection, ProvisionedThroughput and OnDemandThroughput and no warm member, and your measurement here is that a restored table starts with the defaults. The writer in the backup stack (#700, snapshot.rs) builds each manifest GSI field by field from the description and would never set it. So adding it to the v1 pin would freeze a member into the format that no writer emits and that the restore has to ignore. That last part is the risk I'd rather not carry: restore_input_from_manifest in #740 passes the recorded GSIs into the CreateTableInput, so a manifest that did carry WarmThroughput, hand-edited or from a later writer bug, would create the restored index with that value, unlike the service. Bumping to v2 would follow the rule to the letter, but it would shut every older reader out of every newer backup for a member that is always absent, which is the cost the rule accepts only for a real format change.

The underlying problem is that v1 reuses GsiInput and LsiInput, which are CreateTable request types, so any member the request gains changes the persisted format, and this won't be the last one. I tried it on a throwaway worktree of main at 2287d17: BackupGsi and BackupLsi in manifest.rs with exactly the serde names, order and skip_serializing_if of the request types, used by SourceTableSchema and the pinned checks. All 174 backup_format tests pass with no change under testdata/extenddb-manifest/, so the v1 bytes and member pins are unchanged and no version bump is needed. Then, with a stand-in WarmThroughput added to GsiInput (plus warm_throughput: None in the nine literals in validation/mod.rs), nested_types_have_the_pinned_members still passes, where it fails on main with "GsiInput: the members read changed". On main nothing outside backup_format uses SourceTableSchema yet, so the change here stays inside manifest.rs and golden_tests.rs. The writer and reader live in my stack, and I'll adapt them when I rebase: the capture in #700 builds a BackupGsi, and #740's restore maps BackupGsi to GsiInput through a From that sets only the recorded members. If the stack lands first instead, those two call sites are the only other places to change. If ExtendDB later stores a per-index OnDemandThroughput, it gets added to BackupGsi deliberately, with a v2 and its fixtures, matching what the service records.

So in this PR that would be the two types next to SourceTableSchema, the check::<GsiInput> and check::<LsiInput> pins switched to them with the same member lists, and the sentence in the manifest.rs module docs that says nested members reuse the wire types amended to say the index entries are the manifest's own. The prototype diff is about 240 lines, mostly the test literals, and I'm happy to share it. I'll add the revision-log item to docs/design/15-backup-restore.md with the stack's rebase, so this PR doesn't need to touch the design doc.

@robinnsc robinnsc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used three separate reviewers on this one (API behaviour and the engine, storage and upgrades across the four backends, and a verifier that re-ran every finding against the base). For clients that never send WarmThroughput nothing that worked at the base is refused: 46 UpdateTable shapes without the member give the same results on head and base SQLite and on head PostgreSQL apart from the new measured refusal sentences, and the existing UpdateTable, GSI, stream and TTL suites match. The description's rows reproduce on SQLite and PostgreSQL, the three wire files pass (26 each), catalogs from the 0.1.14 SQLite, PostgreSQL and MongoDB images and from a base-binary Cassandra catalog upgrade with the right defaults and their backups restore, nothing can stay UPDATING after a restart since the status is derived at read time, and the Terraform check is real: the base binary fails it with the provider's "couldn't find resource (21 retries)" in 195 s and the head passes in 48 s.

The ones I'd hold this for are the first inline comment and the rebase below: a GSI Update that carries WarmThroughput now drops a ProvisionedThroughput or OnDemandThroughput beside it with a 200, where base and main refuse it. The backup-manifest question is answered in the conversation.

The main thing before this can merge is the rebase onto main's migration framework (#666 and #681), which replaced all three upgrade mechanisms the PR uses. On main serve refuses a catalog with pending migrations, so the PostgreSQL shape steps applied at serve time, SQLite's shape convergence in schema.rs and bootstrapper.rs, and Cassandra's V006 with catalog version 0.0.5 all have to become migration 6 through crates/storage/src/migrations/registry.rs. CONTRIBUTING.md's "Adding a catalog migration" walks through almost exactly this change as its worked example (migration 6, table_note, a nullable column on tables). I think that means a WarmThroughput = 6 entry in the registry with RELEASED_THROUGH left at 0; on PostgreSQL a file body migrations/0006_warm_throughput.sql with ADD COLUMN IF NOT EXISTS on tables and indexes, the arm in migration() and the id in the transactional arm of runs_in(); on SQLite a code body src/migrations/m0006_warm_throughput.rs that checks pragma_table_info first, as lacks_warm_throughput already does, with its golden test and tests/fixtures/golden/0006_warm_throughput.txt; on Cassandra migrations/catalog/0006_warm_throughput.cql with the two ALTER TABLE ... ADD IF NOT EXISTS and no catalog_version insert (step 3 says a body must not name it), dropping V006, the CATALOG_VERSION = "0.0.5" bump and the unmigrated-catalog tolerance, which includes the arm at update_table.rs:173 that today also swallows any read or parse error when the request carries a BillingMode; and on MongoDB a Migration::NotApplicable arm, since the catalog collections have no validator. All of them Kind::Breaking and convergent: true, since additive needs the old-binary job that doesn't exist yet. docs/schema/{sqlite,postgres,cassandra}.txt need regenerating (the integration jobs diff them), and _as_released_catalog in tests/test_resource_tag_migration.py, which clears the ledger of a fresh SQLite catalog, will need to drop the new columns too or migration 1's post-check refuses them.

One trap worth knowing about: merging this branch into main does not report a conflict on the PostgreSQL schema. Rename detection maps the edit of 001_schema.sql onto main's 0001_baseline.sql, and git merge-tree --write-tree origin/main prints "Auto-merging crates/storage-postgres/migrations/0001_baseline.sql" and adds both warm_throughput JSONB columns to migration 1. Migration 1 is a file body checksummed by its contents, so every catalog main has already migrated would report Changed (exit 5), and a fresh init would fail migration 1's post-check with "column tables.warm_throughput is not part of the v1.0 schema". That hunk needs reverting by hand, along with the CREATE TABLE edit in SQLite's schema.rs, which main no longer has.

The upgrade manual's new "Catalog 0.0.5 (Cassandra only)" section also collides with main, where "Catalog 0.0.5" and V006__drop_continuous_backups.cql already mean the continuous-backups drop that became migration 5. I think the section goes away and the "Current Status" line becomes "migrations 1 to 6" with a short note for 6, including that since 6 is Breaking, going back to a release without it means restoring the pre-upgrade backup.

.iter()
.flatten()
.filter_map(|u| u.update.as_ref())
.find(|a| a.warm_throughput.is_none())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An Update that carries WarmThroughput next to ProvisionedThroughput or OnDemandThroughput now succeeds and quietly drops the other member, because UpdateGsiAction only deserializes IndexName and WarmThroughput and this check only looks at warm_throughput.is_none(). On the head SQLite and PostgreSQL builds, Update {IndexName: gsi, ProvisionedThroughput: 9/9, WarmThroughput: {ReadUnitsPerSecond: 10}} on a provisioned 5/5 table answers 200 and the index stays at 5/5, while the same Update without WarmThroughput is refused with "UpdateGlobalSecondaryIndex is not yet supported", which is also what the base and main answer to both. On an on-demand table it gets round the rule in on_demand_update_members: ProvisionedThroughput alone is refused, ProvisionedThroughput plus WarmThroughput is accepted, and an OnDemandThroughput beside WarmThroughput is accepted and not stored. The worst case I found is the request DynamoDB needs to switch an on-demand table with a GSI to PROVISIONED (BillingMode, ProvisionedThroughput 3/3 and the GSI's ProvisionedThroughput 3/3) with a warm value added to the GSI Update: it answers 200 and leaves a provisioned 3/3 table whose index is 0/0 and reports WarmThroughput {12000, 0}. I think UpdateGsiAction needs to read ProvisionedThroughput and OnDemandThroughput, even as opaque values, so that an Update carrying either is still refused whether or not WarmThroughput is present, and then the doc comment at table.rs:1144 ("recognized by the deserializer but not yet implemented") is true again. A unit test per billing mode with both members in one Update would pin it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3546b08. UpdateGsiAction now reads ProvisionedThroughput and OnDemandThroughput as opaque values.

I measured the combinations on DynamoDB first (us-east-1, 2026-11-03). An Update carrying WarmThroughput beside OnDemandThroughput on an on-demand table, beside ProvisionedThroughput or OnDemandThroughput on a 1/1 provisioned table, and your switch shape (BillingMode PROVISIONED, ProvisionedThroughput 3/3, the GSI Update with ProvisionedThroughput 3/3 and a WarmThroughput) were all refused with "One or more parameter values were invalid: WarmThroughput must be the only operation in the request for index: gsi", and both tables were unchanged afterwards.

ExtendDB now answers that sentence in either billing mode, from validate_gsi_updates, before the table is read. An Update without WarmThroughput keeps main's answers (see the reply on update_table.rs:199). a_throughput_beside_warm_throughput_is_refused_in_either_billing_mode sends ProvisionedThroughput, OnDemandThroughput and both, with no BillingMode, PROVISIONED and PAY_PER_REQUEST. With the check taken out of validate_gsi_updates, the test fails on the first case, which is accepted. The doc comment on UpdateGsiAction now says what the two members are read for.

Comment thread tests/python/test_warm_throughput.py Outdated
assert t["WarmThroughput"] == {**ON_DEMAND_DEFAULTS, "Status": "UPDATING"}
if is_extenddb:
_wait_warm_active(dynamodb_client, name)
dynamodb_client.update_table(TableName=name, WarmThroughput=higher)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this re-send hides the one thing U3 leaves open, which is what the value settles on. On ExtendDB, raising a settled on-demand table to 30000/9000 and then sending 12000/4000 5 ms later, inside the 0.25 s window, answers 200 twice and the table settles at {12000, 4000, ACTIVE}, on SQLite and PostgreSQL alike, while the same 12000/4000 on the settled 30000/9000 table is refused as a decrease. So U3 together with apply_update (warm_throughput.rs:226) is a way to lower the value that the decrease rule otherwise refuses. Whether the service settles at 12000 or keeps 30000 isn't in the measurements; it might be worth measuring that once and asserting it on both targets instead of re-sending higher here. If the service keeps the higher value, taking the larger of the stored and requested side in apply_update would match it, and would also close the same decrease through two concurrent UpdateTables, which both validate against the description read before the write.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 33d4e66. I measured it on DynamoDB (us-east-1, 2026-11-03): on an on-demand table and on a GSI, 12200/4200 and then 12000/4000 about 50 ms later both answered 200, and both settled at 12200/4200 ACTIVE, the GSI about nine minutes later and the table about eleven.

apply_update now keeps, per side, the larger of the requested and the stored value, so your 30000/9000 then 12000/4000 sequence settles at 30000/9000. Outside the window a lower request is still refused as a decrease before the merge. The test no longer re-sends higher, so its settled assertion checks this rule on ExtendDB. On the service the settle takes about ten minutes, so as with the other settled rows the docstring records the measurement (row U3b) and the wait runs on ExtendDB only. the_previous_pair_is_reported_and_compared_while_updating asserts the settled pair and a case with one side lower and one higher. With the max rule reverted it fails: the pair settles at 12000/4000 where the test expects 24000/8000.

let json =
serde_json::to_value(record).map_err(|e| StorageError::Internal(e.to_string()))?;
sqlx::query(
"UPDATE indexes SET warm_throughput = $1 \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This write runs after the GSI build and puts the Create's record back unconditionally, so a WarmThroughput Update on the same index that was accepted while the build ran is overwritten. On the head PostgreSQL build with 30000 items, a Create of gidx with {13000, 4100} took 6.9 s; an Update to {ReadUnitsPerSecond: 25000} sent 0.4 s in answered 200 and DescribeTable showed 25000 right after, and once the Create returned the index read {13000, 4100, ACTIVE}. The same script on SQLite ends at 25000, since there the Update waits for the writer. I think adding AND warm_throughput = $4 with the record the Create stored would keep the restart and leave a later Update alone.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ed0a481. update_table keeps the record each created GSI was inserted with, and restart_created_gsi_warm_throughput writes the new deadline with AND warm_throughput = $4 bound to that record, so an Update accepted while the build ran keeps its value. I did not add a test for it: the window needs a build that outlasts the Update's arrival, as in your 30000-item reproduction, which I have not rerun here.

Comment thread crates/engine/src/update_table.rs Resolved
Comment thread devtools/run-tests Outdated
--comprehensive) RUN_COMPREHENSIVE=true; shift ;;
--all) RUN_RUST=true; RUN_RUST_INTEGRATION=true; RUN_PYTEST=true; RUN_EXTERNAL=true; RUN_COMPREHENSIVE=true; shift ;;
--terraform) RUN_TERRAFORM=true; shift ;;
--all) RUN_RUST=true; RUN_RUST_INTEGRATION=true; RUN_PYTEST=true; RUN_EXTERNAL=true; RUN_COMPREHENSIVE=true; RUN_TERRAFORM=true; shift ;;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting --terraform into --all means the documented devtools/run-tests --extenddb --all (developer test guide line 129, AGENTS.md line 218, tests/README.md line 37) now needs access to releases.hashicorp.com and registry.terraform.io, and fails on macOS or arm64 since install-terraform.sh only fetches linux_amd64. The binary is cached in $TMPDIR/terraform-1.17.0 after the first run, but the provider lands in a fresh mktemp directory every time. CI passes --terraform explicitly, so it wouldn't lose anything if --all left it out, or skipped it with a message off linux/x86_64. Separately, main.tf only creates, plans and destroys, so the update paths this PR changes (a GSI added, a billing switch) have no provider-level check; a second apply with a change might be worth adding.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in cce4348: --all leaves --terraform out and the help text says so. CI still passes --terraform.

The second apply is a follow-up issue, #800: a changed variable that switches example to PROVISIONED and adds a GSI to example-with-index, a second apply, and a plan that must report no changes.

deletion_protection_enabled: None,
table_class: None,
on_demand_throughput: None,
warm_throughput: None,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table-level member is dropped here, but each GSI's WarmThroughput still comes through global_secondary_indexes: tcp.global_secondary_indexes.clone() and ImportTable never runs CreateTable's validation, so an imported provisioned 5/5 index with WarmThroughput: {ReadUnitsPerSecond: -7, WriteUnitsPerSecond: 0} is stored and reported as -7 while CreateTable refuses the same GSI. It isn't new in kind, since a GSI ProvisionedThroughput of -3 goes through ImportTable on the base build too, so I'd either clear the GSI member here as well for consistency or, probably better as its own issue, run validate_create_table on the import's create input.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in 9fc0a41: the import clears each GSI's WarmThroughput as it does the table's, so an imported table and its indexes report the defaults. an_imported_gsi_warm_throughput_is_cleared uses your index with -7, and without the clear it fails with the -7 still on the index. Running validate_create_table on the import's create input belongs with #771, where I added the -3 ProvisionedThroughput reproduction from main.

@navareamol navareamol added the v1 Needed for the 1.0 release label Nov 3, 2026
@navareamol navareamol added this to the 1.0 milestone Nov 3, 2026
main replaced the three upgrade mechanisms this branch used (#666, #681):
serve refuses a catalog with pending migrations, so the PostgreSQL shape
steps applied at serve time, SQLite's shape convergence and Cassandra's
V006 with catalog version 0.0.5 cannot run any more. The columns are now
migration 6, `warm_throughput`, in crates/storage/src/migrations/registry.rs,
Breaking and convergent on every backend, with RELEASED_THROUGH left at 0:

- PostgreSQL: migrations/0006_warm_throughput.sql, ADD COLUMN IF NOT EXISTS
  on tables and indexes, run in a transaction.
- SQLite: the code body m0006_warm_throughput.rs, which reads
  pragma_table_info before each ALTER TABLE, with a golden test on the
  0.1.14 catalog (tests/fixtures/golden/0006_warm_throughput.txt).
- Cassandra: migrations/catalog/0006_warm_throughput.cql with two ALTER
  TABLE ... ADD IF NOT EXISTS and no catalog_version insert. V006 is gone.
- MongoDB: NotApplicable, since the catalog collections have no validator.

The merge left migration 1 and SQLite's schema.rs as main has them, so no
warm_throughput hunk reached 0001_baseline.sql. The tests that pin the
latest migration or a catalog's definitions after every migration now
expect 6, and _as_released_catalog in tests/test_resource_tag_migration.py
drops the two columns so migration 1's check of the v1.0 schema accepts the
catalog. The upgrade manual drops this branch's Catalog 0.0.5 section,
which collided with main's continuous-backups drop, and describes
migration 6 under Current Status, including that going back to a release
without it means restoring the backup taken before the upgrade. The
verify examples in the install guides read migration 6, and
docs/schema/{sqlite,postgres,cassandra}.txt are regenerated from a fresh
init.

Literals added on main since the branch point gain the new members:
GsiInput in crates/storage/src/snapshot_conformance.rs and in two Cassandra
direct tests, and UpdateTableInput and CreateGsiAction in another. The
SQLite warm throughput tests build their catalog with
migrations::apply_for_tests and insert control_plane_delay_seconds, which
no migration seeds.
The v1 manifest recorded the source table's indexes as GsiInput and
LsiInput, the CreateTable request types, so this branch's WarmThroughput
member on GsiInput changed the persisted format and failed
nested_types_have_the_pinned_members. A backup does not record warm
throughput: DescribeBackup's GlobalSecondaryIndexInfo has no warm member,
and a restored table starts with the defaults.

BackupGsi and BackupLsi in manifest.rs carry the serde names, member
order and skip_serializing_if the request types had when format version 1
was frozen, without WarmThroughput. SourceTableSchema uses them, the
member pins check them with the same member lists, and the module docs
say the index entries are the manifest's own. The fixtures under
testdata/extenddb-manifest/ are unchanged, so no format version bump.
…mThroughput

UpdateGsiAction deserialized only IndexName and WarmThroughput, so an
Update carrying ProvisionedThroughput or OnDemandThroughput next to
WarmThroughput answered 200 and dropped the other member. On an on-demand
table switched to PROVISIONED in the same request, the index was left at
0/0. It now reads both members as opaque values.

Measured on DynamoDB (us-east-1, 2026-11-03): an Update carrying
WarmThroughput beside OnDemandThroughput on an on-demand table, beside
ProvisionedThroughput or OnDemandThroughput on a provisioned table, and in
the request that switches an on-demand table with a GSI to PROVISIONED,
is refused with "One or more parameter values were invalid:
WarmThroughput must be the only operation in the request for index: gsi".
The rule does not depend on the billing mode, so it is checked with the
other element rules, before the table is read.

An Update without WarmThroughput is refused once the table is read, under
the billing mode the table has after the request: the request's
BillingMode when it carries one, the stored mode otherwise. Under
PAY_PER_REQUEST one carrying ProvisionedThroughput or nothing gets the
measured on-demand sentence; one carrying only OnDemandThroughput, and any
under PROVISIONED (the index update of a switch to PROVISIONED included),
gets "UpdateGlobalSecondaryIndex is not yet supported", as on main.
…ne in progress

Inside the UPDATING window a request is validated against the values the
window started from, so it can be lower than the change in progress.
apply_update wrote the requested side, which lowered the value the
decrease rule otherwise refuses.

Measured on DynamoDB (us-east-1, 2026-11-03): on an on-demand table and on
a GSI, 12200/4200 and then 12000/4000 about 50 ms later both answered 200,
and each settled at 12200/4200 ACTIVE. apply_update now keeps, per side,
the larger of the requested and the stored value. Outside the window a
lower request is refused before it reaches the merge, so nothing changes
there.

The wire test no longer re-sends the higher values after U3, so its
settled assertion checks this rule on ExtendDB; the service takes about
ten minutes to settle, which the docstring records with the measurement.
…a side

MongoDB read the record with find_one and wrote the merge back with $set,
and Cassandra read the column and wrote it through the table LWT
(conditional only on IF EXISTS) and a plain UPDATE of the index row, so two
UpdateTables that set different sides could both answer 200 while one
side was lost.

- MongoDB: the update_one filter includes the field as read; when nothing
  matches, the document is read again and the merge retried.
- Cassandra: with a WarmThroughput, the table LWT is conditional on
  table_id and on the record read; a GSI's record is written by its own
  LWT, conditional on index_type and the record read. Both read again and
  retry when the condition fails. The BillingMode arm that let a switch to
  PAY_PER_REQUEST skip the column on an unmigrated catalog, and swallowed
  any read or parse error with it, is gone: migration 6 runs before a
  server serves the catalog.
- PostgreSQL: the restart of a created GSI's UPDATING window after the
  build is conditional on the record the Create inserted, so an Update of
  the index accepted while the build ran keeps its value.

A stored record that does not parse (a hand edit, or a shape this build
does not know) is now logged and read as never set on every backend, as
the neighbouring on_demand_throughput column is read. DescribeTable reports
the defaults, and UpdateTable writes a record over it, where every
description build failed with a 500 before.

A wire test sends ten rounds of two UpdateTables together, one per side,
on the table and on a GSI, and asserts both sides settle. It runs on
ExtendDB only, since the service bills each increase.
ImportTable drops the table-level member, since TableCreationParameters
has none, but passed each GSI's WarmThroughput through, and ImportTable
does not run CreateTable's validation, so a value CreateTable refuses (-7
read units) was stored and reported. The import now clears it, and the
imported table and its indexes report the defaults. Running CreateTable's
validation on the import's create input, which also lets a GSI
ProvisionedThroughput of -3 through on main, is left to its own issue.
devtools/run-tests --extenddb --all is the documented local command
(developer test guide, AGENTS.md, tests/README.md). With --terraform in
--all it needed releases.hashicorp.com and registry.terraform.io and failed
on macOS and arm64, since install-terraform.sh only fetches linux_amd64.
CI passes --terraform explicitly, so --all now leaves it out and the help
text says so.
Main added catalog migrations 6 (backup_catalog_index) and 7
(stream_pending), so the warm_throughput migration moves from 6 to 8. The
registry entry, each backend's registration and the migration tests now
name 8. So do the SQLite module m0008_warm_throughput.rs with its golden
test and fixture, the PostgreSQL and Cassandra files
0008_warm_throughput.sql and 0008_warm_throughput.cql,
devtools/check-postgres-catalog-lock and the manuals.

The MongoDB migration tests keep main's MigrationId::LATEST checks and count
migration 8 in their literal step counts and ids.

The Cassandra migration tests use main's expected_definitions helper, which
now also adds the warm_throughput columns, in place of after_every_migration.

The Cassandra CreateTable insert adds the warm_throughput column before main
builds its placeholder list, so the restore job placeholders stay aligned
with their columns.

Main's source_table_schema in crates/storage/src/snapshot.rs builds the
manifest's BackupGsi and BackupLsi entries in place of GsiInput and LsiInput.

Main's music_table test fixture in the engine's backup tests sets the two
WarmThroughput fields of GsiDescription to None.

The migration example in CONTRIBUTING.md moves to id 9, the next free id.

Signed-off-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>
…p store

Since #700, the PostgreSQL and SQLite jobs run the Python suite against a
server with a filesystem backup store. CreateBackup there writes to the
store, and RestoreTableFromBackup refuses such a backup until the restore
job lands. S6c and S6d restore the backup, so they now skip on that
server, as the restore tests on main do. S6b still runs on every server.

Signed-off-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

I merged main into this branch as a1badc3. Main now has catalog migrations 6 (backup_catalog_index) and 7 (stream_pending), so the migration of this PR is now 8. The merge renames its files to 0008_warm_throughput and moves its tests and docs to 8.

Two new pieces of main needed a change to build with this branch. crates/storage/src/snapshot.rs now builds the manifest's BackupGsi and BackupLsi types. In the engine's backup tests, music_table() sets the two new GsiDescription fields to None.

Since #700, the PostgreSQL and SQLite jobs run with a filesystem backup store. RestoreTableFromBackup refuses a backup in a store until the restore job lands. d8879f9 makes S6c and S6d skip there, as the restore tests on main do. S6b runs on every server.

The description now matches. @robinnsc, can you take another look?

devtools/run-tests sets control_plane_delay_seconds to 0.05, so the
UPDATING window that a WarmThroughput change opens lasts 50 ms on
ExtendDB. The server reads its clock when it writes the change and again
when it builds the response. If 50 ms or more pass between the two
reads, the response reports the new pair as ACTIVE. The MongoDB job of
d8879f9 failed this way in U3, which answered 200 with the settled
24000/8000 pair and ACTIVE.

Two helpers now check the responses of U1, U2, S2c, U6, S8a and T7, and
of the index update beside a table update. Against the service they
assert what the test asserted before. On ExtendDB they also accept the
new pair with ACTIVE when the call took at least 50 ms.

U3 also accepts the S2b refusal and the higher pair with UPDATING,
because the window of U2 can end at any point of U3. U3b still checks
the settled pair.

Signed-off-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

The MongoDB job of d8879f9 failed in U3 of test_update_warm_throughput_goes_updating_then_active, which answered with the settled 24000/8000 pair and ACTIVE. devtools/run-tests sets the control plane delay to 0.05 seconds. So the UPDATING window that a request opens lasts 50 milliseconds, and a response that the server builds after that reports the new pair.

4a1926f lets the warm throughput wire tests accept that answer on ExtendDB when the call took 50 milliseconds or more. Against the service they assert what they asserted before.

#868 moves the UpdateTableInput that two Cassandra index tests build into
one helper, status_index_creation. The helper now sets the
sse_specification and warm_throughput fields that this branch adds.

Signed-off-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

I merged main again as 64398e1. #868 moved the UpdateTableInput of the Cassandra index tests into one helper, status_index_creation. The helper now sets the sse_specification and warm_throughput fields of this branch.

Main added catalog migration 8 (restore_progress) in #740, so the
warm_throughput migration moves from 8 to 9. The registry entry, each
backend's registration, the migration tests, the getting-started guide and
the manuals now name 9. So do the SQLite module m0009_warm_throughput.rs
with its golden test and fixture, the PostgreSQL and Cassandra files
0009_warm_throughput.sql and 0009_warm_throughput.cql,
devtools/check-postgres-catalog-lock and tests/test_resource_tag_migration.py.

Since #740 restores a backup from a backup store, this merge removes the
skip of S6c and S6d in tests/python/test_warm_throughput_backup.py.

Main's restore_input_from_manifest and its manifest_from_source test helper
convert between the manifest's BackupGsi and BackupLsi entries and GsiInput
and LsiInput. A GSI that a store-backed restore creates gets no warm
throughput.

The GsiInput entries of two restore tests from #740 set warm_throughput to
None.

The MongoDB migration tests count migration 9 in their step counts, ids and
not-applicable lists, and the id of the later binary is now 10.

The upgrade manual keeps main's text on migration 8 and names migrations 1
to 7 and 9 as breaking.

The migration example in CONTRIBUTING.md moves to id 10, the next free id.

Signed-off-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

I merged main again as 663c5a3. #740 added catalog migration 8 (restore_progress), so the migration of this PR is now 9. The merge renames its files to 0009_warm_throughput and moves its tests and docs to 9.

#740 also brought a restore job that reads the backup manifest. Its restore_input_from_manifest now converts the manifest's BackupGsi and BackupLsi to the CreateTable index types, and each restored GSI gets no WarmThroughput.

With the restore job on main, the skip from d8879f9 is gone, so S6c and S6d run on every server again. On a server with a backup store, they restore through the job, and this push's CI is their first run there.

@robinnsc, can you take another look?

@LeeroyHannigan
LeeroyHannigan merged commit 2671ee1 into main Nov 9, 2026
49 checks passed
@LeeroyHannigan
LeeroyHannigan deleted the fix/462-warm-throughput branch November 9, 2026 13:00
LeeroyHannigan added a commit that referenced this pull request Nov 9, 2026
Main (#474) added an "Install Terraform" step after the "Build release"
step of mongodb-pytest and cassandra-pytest, and --terraform to their
test commands. This branch replaced those build steps with a download of
the shared binary and a chmod. These were the only conflicts. Each job
now has the download and the chmod, then main's Terraform step.

The same Terraform changes to run-integration and run-integration-sqlite
merged without conflicts. So did main's changes to devtools/run-tests and
devtools/check-postgres-catalog-lock.
LeeroyHannigan added a commit that referenced this pull request Nov 9, 2026
crates/engine/src/update_table.rs: main (#474) moved
validate_gsi_updates and its tests to the new
crates/engine/src/gsi_updates.rs. It also changed the rules there, for
the Update action and for an index that the request names twice. This
branch reports a Create or Delete index name outside the pattern at its
member path, through validate_update_index_name. The result takes main's
update_table.rs. It moves validate_update_index_name, its two calls and
the unit test an_index_name_outside_the_pattern_is_reported_at_its_member_path
into gsi_updates.rs. The name of an Update keeps the bare indexName
location, because its member path is not measured.
LeeroyHannigan added a commit that referenced this pull request Nov 9, 2026
crates/storage-cassandra/src/table_helpers.rs: main (#474) reads an
index's warm_throughput where this branch reads its backfill_heartbeat,
in the same place. The result keeps both reads.

Main added warm_throughput to CreateGsiAction, and warm_throughput and
sse_specification to UpdateTableInput. This branch's
crates/storage-cassandra/tests/direct/gsi_backfilling.rs builds both
types, and now sets the new fields to None. This branch added
backfilling to GsiDescription. The test helper on_demand_table in main's
crates/engine/src/warm_throughput.rs builds one for an ACTIVE index, and
now sets it to None.
LeeroyHannigan added a commit that referenced this pull request Nov 9, 2026
This resolves the conflict in the upgrade manual. #474 added the
migration 9 paragraph, and #740 rewrote the backup store paragraph
after it. The merge keeps both paragraphs as main has them. In the
backup store paragraph, it applies the one change of this branch: a
later major release refuses CreateBackup without a store.

Signed-off-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>
robinnsc added a commit that referenced this pull request Nov 10, 2026
The integration workflow's PostgreSQL and SQLite jobs ran the wire suite
with `--filter "not import_export"`. The filter came with the PostgreSQL
job's first version (687e46f) and was copied into the SQLite job
(556c501); neither commit gives a reason. A foreground server wrote a
PID file in every tree up to e0d6a0a, which made foreground mode write
none by default and added `--write-pid-file` to the job in the same
commit; 556c501 came after e0d6a0a. So the restart
`devtools/run-tests` makes for the import and export tests could stop
the job's server in every tree, and the filter was not working around
it. The MongoDB and Cassandra jobs already run
`tests/test_import_export.py` unfiltered. The expression selects out
that file's ten tests and nothing else. Run the job's way on release
builds of this change they pass 10 of 10 on SQLite and on PostgreSQL,
before and after its rebase onto main 887b6e2, so both filters go and
no narrower one stays. Both lines already carry main's `--terraform`
(#474); this change removes the filter only, so each reads
`devtools/run-tests --extenddb --pytest --comprehensive --terraform
--parallel`.

`docs/design/15-backup-restore-bench-pr11.md` (row 15d of the design
index) records the cells the testing summary left open, in the PR 9
record's method: release builds, a filesystem store, the server
restarted before each phase, `VmHWM` sampled every 200 ms, on the
16-core host class of the earlier records. 1M items of 200 bytes restore
in 33.8 s on MongoDB (its own backup) and 49.0 s on Cassandra (a SQLite
backup adopted with `backup sync`), 52 and 33 MiB over idle. A 1M-item
table with a 128-dimension vector index backs up in 243 s on PostgreSQL
and 210 s on SQLite and restores in 246 s and 214 s, 111 MiB and 552 MiB
over idle; SQLite's figure is higher than at 100k under glibc's default
arenas and is 204 MiB, flat from 100k, under `MALLOC_ARENA_MAX=1`, where
the backup took 222 s and the restore 283 s. The Cassandra cells ran on
a node of their own with the Cassandra workflow's service settings. No
cell is left open. Later runs on the same host, also in the record,
reproduce the cells and show that SQLite's restore memory is its write
batch and decode chunks, not the vector index: it grows with the item's
size up to the 32 MiB batch bound whatever the attribute types (253 MiB,
130 MiB under one arena, for 100k items of 2.5 KB strings), and lists of
numbers decode larger (397 to 424 MiB for the same 100k items of 128
numbers with no index, 301 to 316 MiB under one arena for 20,000 items
of 1,536 numbers). Two restores at once under one arena took 57.5 s
against 24.9 s. Five pairs of PostgreSQL runs with and without the
vector index, each pair from one harness, put its share of the 100k
restore at 27 to 53 MiB and 33 to 47% of the duration. A MongoDB restore
becomes ACTIVE at the backfill worker's next 5 s cycle after its load,
so it takes the load's time plus up to 5 s. These figures come from
release builds of earlier versions of this change, on PR 10 at 358ff8b
and main 94b5f68, before main's later changes to the backup and restore
code (#700 and #740 as merged, and #474); the 100k cells, run again on
release builds after the rebase onto main 887b6e2, reproduce in kind
(peaks within 8.4%, durations up to 32% longer at two to four times the
host load).

`docs/manuals/14-backup-and-restore.md` is the operator's manual,
derived from the design: the strategy (its first sentence: a filesystem
store keeps the host's failure domain, S3 is the production
recommendation), RPO and RTO per store kind with the three records'
figures and host class (a key-ordered PostgreSQL backup also needs the
text key columns at collation `C` or `POSIX`, and the server logs a
warning when it streams an older table unordered; the vector index's
share of the SQLite restore comes from two sets of runs on a lightly
loaded host, and the record's loaded set is given and left out of the
share), the configuration (pointing at the admin guide's rows and the
store crate's README; an S3 store needs root certificates,
`ca-certificates` or `SSL_CERT_FILE`; a split-root identity mismatch is
cleared by no command in this release, since `backup purge --confirm`,
plain `backup sync` and `--prune-missing` refuse an unhealthy store, and
the manual and the deployment guide give the two remedies that exist, a
catalog copy from before the split or one directory's rows deleted by
hand and its backups copied into the kept directory), securing the
store, what a running backup costs each database, a restore drill,
catalog-loss recovery with `backup sync`, `--adopt-store` and the
in-memory startup sync (the old key pairs imported once
`allow_credential_import` is turned on, with `extenddb settings` or, on
an in-memory server, the management API, and off again after), legacy
backups and what to do with them while `migrate-legacy` (#821) is not
shipped, what a restore preserves, and moving data to and from Amazon
DynamoDB with ImportTable and export (a store-prefix import is #748). It
states each deployment statement the design's PR 11 acceptance lists.
Figures measured for it, with their method in the record's "Figures
measured for the manual": a 25 s PostgreSQL backup beside 12,156
overwrites of 200-byte items grew the written table from 0.4 to 4.4 MiB,
its dead row versions not removable by a `VACUUM` during the backup (0.5
MiB with no backup); on SQLite the WAL grows by the pages each write
changes, from 4.0 to 61.1 MiB over 15,472 writes to a table with no
index during a 22.8 s backup and from 4.1 to 1,294 MiB over 13,996
writes to a table with two GSIs during a 25.6 s backup (about 20 to 24
pages per write over four runs).

The manual's process-level statements were checked on release builds of
this change before its rebase onto main 887b6e2, SQLite and PostgreSQL:
the root placement refusals and their texts, the drill, an off-host copy
under account and table directories made 0700 (a `mkdir -p` under a 022
umask stops sync until `chmod -R` on the account directory), a
re-created catalog's config file (`init --overwrite` regenerates every
section from defaults and carries over only the storage settings, so a
`port` or TLS path edited in a default section reverts too and the copy
taken first goes back whole apart from those settings) and its store
health with an explicit store and with SQLite's default root
(unconfigured, with CreateBackup writing in-catalog backups until the
adoption), the accounts re-created with their old ids and old key pairs
imported, the adoption, the in-memory startup sync and, on the in-memory
dev build, the adopted backups refused until their account is
re-created, the in-catalog create's warning and the restore of its
backup through a store-configured server, an S3 store at moto with the
default spool, `backup sync` exiting 6 beside a SQLite server,
ImportTable refusing a gzip file and both kinds of symbolic link and
importing a decompressed backup data file, an off-host copy with loose
modes refused by `backup sync`, and on PostgreSQL the claim session
found by its lock key, whose termination stops the job at its next
heartbeat and leaves the row to the reconciler, the registration
session's termination failing the server's running backups, the wait of
`--prune-missing` on a recently failed backup, a catalog restored alone
beside a newer data database, and the catalog and data dumps restored
into new databases. On PostgreSQL 16 containers the restore the admin
guide now gives ran end to end, on the old server and on a new, empty
one, and an access key was imported through the management API from a
request body read from a file. Since main's #840 the server refuses an
access key import unless `allow_credential_import` is `true`, and a
re-created catalog has no value for it: on PostgreSQL and on an
in-memory SQLite server, release builds of this tree answer the manual's
import with 403 "Credential import is disabled (allow_credential_import
= false)" and import the pair once the setting is on (`extenddb settings
set` beside the running server; on the in-memory server, which `extenddb
settings` cannot reach, `PUT
/management/settings/allow_credential_import`), and the imported pairs
keep signing requests after it is turned off. Release builds after the
rebase repeated the root placement refusals, what a restore preserves,
the drill on SQLite, PostgreSQL and an S3 store at moto, the off-host
copy shapes, a catalog restored from dumps and the claim and
registration sessions on PostgreSQL, a catalog lost and re-created on
SQLite with `--adopt-store`, the in-memory startup sync, the legacy
path, ImportTable and export, the split-root remedy by hand on SQLite,
the admin guide's Data Recovery entry on PostgreSQL 16 and `init`'s
database names.

The admin guide's Data Recovery entry named the PostgreSQL data database
`extenddb_catalog_data`; `init` names it after the catalog without its
`_catalog` suffix (`extenddb` by default). The entry now lists each
backend's databases, says a catalog name without the suffix needs
`--data-db` and that the failed `init` leaves the catalog database to
drop first, and treats the two PostgreSQL databases as one copy: both
dumps with the server stopped, under `umask 077` since the catalog dump
holds the encryption key and the application role's password, or a base
backup; the restore goes into new, empty databases created with
`createdb -O` by the admin role, since one over the existing databases
restores nothing and one into databases the admin role owns leaves the
server unable to create tables. The old databases are renamed aside
until the restored server has read every table; the dumps use the
server's major version of `pg_dump` and are checked non-empty, since an
older one exits 1 leaving an empty file that `psql` restores without an
error; and on a new server the application role is created first with
the dump's password and, at another address, the catalog's recorded
data-database address is set, or the server keeps using the old one. The
SQLite row gives the restore with the current `-wal` and `-shm` removed.
The security model and the deployment guide's checklist say the same,
and the upgrade manual's dumps take `umask 077` and are checked (`test
-s`), and its rollback renames both databases aside, restores them with
`ON_ERROR_STOP` and drops the renamed copies once the previous binary
has read every table; the checklist limits a base backup to both
databases on one instance. The architecture, design, quickstart and
security-model guides, AGENTS.md, the troubleshooting guide, the
technical-debt register (whose A-1 entry now cites functions, not moved
line numbers) and the storage-extension guide carry the right name, the
quickstart's `init` table gives the PostgreSQL admin and application
roles' flags with their defaults, and `init --help` states both database
defaults and that only the PostgreSQL backend reads the two flags. The
admin guide's `[backup]` section and the upgrade manual's backup
paragraph point at the manual; the upgrade manual's shared-root and
re-created-catalog sentences move there. The admin guide's
`max_concurrent_jobs` row says that SQLite restores of items larger than
a few hundred bytes hold more and points at the manual, its backup
commands' paragraph gives the exit codes 3, 4 and 5 on a catalog `serve`
refuses, and the deployment guide's checklist has a `[backup.store]`
line. ADR-0019's Status line says it is superseded in part by the
design, whose section 10 states what that covers, a form
`docs/adr/README.md` now names; the Cassandra RFC's "Backup and restore"
section carries a note, superseded in part, since CreateBackup on
Cassandra still writes their in-catalog format, and its lines on
synchronous operations and on restored indexes carry notes too. The
differences document gives the 1M MongoDB and Cassandra restore figures.
`docs/build-docs.py` lists the manual as document 19 (the build renders
all 19), and the README's and AGENTS.md's documentation tables have a
row for it (AGENTS.md's Extending Storage row now names its file). The
quickstart and the `extenddb` skill say that `init` refuses an existing
config file without `--overwrite`.

The design's testing summary states the measured cells in place of
"still to be measured", section 7 says what a SQLite restore of items
larger than a few hundred bytes holds, the PR 11 section's line says
what shipped, and revision item 35 records the filter history, the
measurements, the manual and the database-name correction.

Co-authored-by: Lee <leeroyhannigan@yahoo.ie>
Signed-off-by: Scott Robinson <robinnsc@amazon.com>
robinnsc added a commit that referenced this pull request Nov 10, 2026
The integration workflow's PostgreSQL and SQLite jobs ran the wire suite
with `--filter "not import_export"`. The filter came with the PostgreSQL
job's first version (687e46f) and was copied into the SQLite job
(556c501); neither commit gives a reason. A foreground server wrote a
PID file in every tree up to e0d6a0a, which made foreground mode write
none by default and added `--write-pid-file` to the job in the same
commit; 556c501 came after e0d6a0a. So the restart
`devtools/run-tests` makes for the import and export tests could stop
the job's server in every tree, and the filter was not working around
it. The MongoDB and Cassandra jobs already run
`tests/test_import_export.py` unfiltered. The expression selects out
that file's ten tests and nothing else. Run the job's way on release
builds of this change they pass 10 of 10 on SQLite and on PostgreSQL,
before and after its rebase onto main 887b6e2, so both filters go and
no narrower one stays. Both lines already carry main's `--terraform`
(#474); this change removes the filter only, so each reads
`devtools/run-tests --extenddb --pytest --comprehensive --terraform
--parallel`.

`docs/design/15-backup-restore-bench-pr11.md` (row 15d of the design
index) records the cells the testing summary left open, in the PR 9
record's method: release builds, a filesystem store, the server
restarted before each phase, `VmHWM` sampled every 200 ms, on the
16-core host class of the earlier records. 1M items of 200 bytes restore
in 33.8 s on MongoDB (its own backup) and 49.0 s on Cassandra (a SQLite
backup adopted with `backup sync`), 52 and 33 MiB over idle. A 1M-item
table with a 128-dimension vector index backs up in 243 s on PostgreSQL
and 210 s on SQLite and restores in 246 s and 214 s, 111 MiB and 552 MiB
over idle; SQLite's figure is higher than at 100k under glibc's default
arenas and is 204 MiB, flat from 100k, under `MALLOC_ARENA_MAX=1`, where
the backup took 222 s and the restore 283 s. The Cassandra cells ran on
a node of their own with the Cassandra workflow's service settings. No
cell is left open. Later runs on the same host, also in the record,
reproduce the cells and show that SQLite's restore memory is its write
batch and decode chunks, not the vector index: it grows with the item's
size up to the 32 MiB batch bound whatever the attribute types (253 MiB,
130 MiB under one arena, for 100k items of 2.5 KB strings), and lists of
numbers decode larger (397 to 424 MiB for the same 100k items of 128
numbers with no index, 301 to 316 MiB under one arena for 20,000 items
of 1,536 numbers). Two restores at once under one arena took 57.5 s
against 24.9 s. Five pairs of PostgreSQL runs with and without the
vector index, each pair from one harness, put its share of the 100k
restore at 27 to 53 MiB and 33 to 47% of the duration. A MongoDB restore
becomes ACTIVE at the backfill worker's next 5 s cycle after its load,
so it takes the load's time plus up to 5 s. These figures come from
release builds of earlier versions of this change, on PR 10 at 358ff8b
and main 94b5f68, before main's later changes to the backup and restore
code (#700 and #740 as merged, and #474); the 100k cells, run again on
release builds after the rebase onto main 887b6e2, reproduce in kind
(peaks within 8.4%, durations up to 32% longer at a host load of 5.3 to
11.0 against 1.3 to 6.4 for the earlier cells).

`docs/manuals/14-backup-and-restore.md` is the operator's manual,
derived from the design: the strategy (its first sentence: a filesystem
store keeps the host's failure domain, S3 is the production
recommendation), RPO and RTO per store kind with the three records'
figures and host class (a key-ordered PostgreSQL backup also needs the
text key columns at collation `C` or `POSIX`, and the server logs a
warning when it streams an older table unordered; the vector index's
share of the SQLite restore comes from two sets of runs on a lightly
loaded host, and the record's loaded set is given and left out of the
share), the configuration (pointing at the admin guide's rows and the
store crate's README; an S3 store needs root certificates,
`ca-certificates` or `SSL_CERT_FILE`; a split-root identity mismatch is
cleared by no command in this release, since `backup purge --confirm`,
plain `backup sync` and `--prune-missing` refuse an unhealthy store, and
the manual and the deployment guide give the two remedies that exist, a
catalog copy from before the split, keeping the directory whose store id
its rows carry, or one directory's rows deleted by hand from the
`backup_index` table or collection (on Cassandra `backups_by_arn` and
`backup_index_by_status`) by `store_id`, with the other directory's
account directories copied into the kept one under the drill's copy
rules before `backup sync`), securing the
store, what a running backup costs each database, a restore drill,
catalog-loss recovery with `backup sync`, `--adopt-store` and the
in-memory startup sync (the old key pairs imported once
`allow_credential_import` is turned on, with `extenddb settings` or, on
an in-memory server, the management API, and off again after), legacy
backups and what to do with them while `migrate-legacy` (#821) is not
shipped, what a restore preserves, and moving data to and from Amazon
DynamoDB with ImportTable and export (a store-prefix import is #748). It
states each deployment statement the design's PR 11 acceptance lists.
Figures measured for it, with their method in the record's "Figures
measured for the manual": a 25 s PostgreSQL backup beside 12,156
overwrites of 200-byte items grew the written table from 0.4 to 4.4 MiB,
its dead row versions not removable by a `VACUUM` during the backup (0.5
MiB with no backup); on SQLite the WAL grows by the pages each write
changes, from 4.0 to 61.1 MiB over 15,472 writes to a table with no
index during a 22.8 s backup and from 4.1 to 1,294 MiB over 13,996
writes to a table with two GSIs during a 25.6 s backup (about 20 to 24
pages per write over four runs).

The manual's process-level statements were checked on release builds of
this change before its rebase onto main 887b6e2, SQLite and PostgreSQL:
the root placement refusals and their texts, the drill, an off-host copy
under account and table directories made 0700 (a `mkdir -p` under a 022
umask stops sync until `chmod -R` on the account directory), a
re-created catalog's config file (`init --overwrite` regenerates every
section from defaults and carries over only the storage settings, so a
`port` or TLS path edited in a default section reverts too and the copy
taken first goes back whole apart from those settings) and its store
health with an explicit store and with SQLite's default root
(unconfigured, with CreateBackup writing in-catalog backups until the
adoption), the accounts re-created with their old ids and old key pairs
imported, the adoption, the in-memory startup sync and, on the in-memory
dev build, the adopted backups refused until their account is
re-created, the in-catalog create's warning and the restore of its
backup through a store-configured server, an S3 store at moto with the
default spool, `backup sync` exiting 6 beside a SQLite server,
ImportTable refusing a gzip file and both kinds of symbolic link and
importing a decompressed backup data file, an off-host copy with loose
modes refused by `backup sync`, and on PostgreSQL the claim session
found by its lock key, whose termination stops the job at its next
heartbeat and leaves the row to the reconciler, the registration
session's termination failing the server's running backups, the wait of
`--prune-missing` on a recently failed backup, a catalog restored alone
beside a newer data database, and the catalog and data dumps restored
into new databases. On PostgreSQL 16 containers the restore the admin
guide now gives ran end to end, on the old server and on a new, empty
one, and an access key was imported through the management API from a
request body read from a file. Since main's #840 the server refuses an
access key import unless `allow_credential_import` is `true`, and a
re-created catalog has no value for it: on PostgreSQL and on an
in-memory SQLite server, release builds of this tree answer the manual's
import with 403 "Credential import is disabled (allow_credential_import
= false)" and import the pair once the setting is on (`extenddb settings
set` beside the running server; on the in-memory server, which `extenddb
settings` cannot reach, `PUT
/management/settings/allow_credential_import`), and the imported pairs
keep signing requests after it is turned off. Release builds after the
rebase repeated the root placement refusals, what a restore preserves,
the drill on SQLite, PostgreSQL and an S3 store at moto, the off-host
copy shapes, a catalog restored from dumps and the claim and
registration sessions on PostgreSQL, a catalog lost and re-created on
SQLite with `--adopt-store`, the in-memory startup sync, the legacy
path, ImportTable and export, the split-root remedy by hand on SQLite,
the admin guide's Data Recovery entry on PostgreSQL 16 and `init`'s
database names.

The admin guide's Data Recovery entry named the PostgreSQL data database
`extenddb_catalog_data`; `init` names it after the catalog without its
`_catalog` suffix (`extenddb` by default). The entry now lists each
backend's databases, says a catalog name without the suffix needs
`--data-db` and that the failed `init` leaves the catalog database to
drop first, and treats the two PostgreSQL databases as one copy: both
dumps with the server stopped, under `umask 077` since the catalog dump
holds the encryption key and the application role's password, or a base
backup; the restore goes into new, empty databases created with
`createdb -O` by the admin role, since one over the existing databases
restores nothing and one into databases the admin role owns leaves the
server unable to create tables. The old databases are renamed aside
until the restored server has read every table; the dumps use the
server's major version of `pg_dump` and are checked non-empty, since an
older one exits 1 leaving an empty file that `psql` restores without an
error; and on a new server the application role is created first with
the dump's password and, at another address, the catalog's recorded
data-database address is set, or the server keeps using the old one. The
SQLite row gives the restore with the current `-wal` and `-shm` removed.
The security model and the deployment guide's checklist say the same,
and the upgrade manual's dumps take `umask 077` and are checked (`test
-s`), and its rollback renames both databases aside, restores them with
`ON_ERROR_STOP` and drops the renamed copies once the previous binary
has read every table; the checklist limits a base backup to both
databases on one instance. The architecture, design, quickstart and
security-model guides, AGENTS.md, the troubleshooting guide, the
technical-debt register (whose A-1 entry now cites functions, not moved
line numbers) and the storage-extension guide carry the right name, the
quickstart's `init` table gives the PostgreSQL admin and application
roles' flags with their defaults, and `init --help` states both database
defaults and that only the PostgreSQL backend reads the two flags. The
admin guide's `[backup]` section and the upgrade manual's backup
paragraph point at the manual; the upgrade manual's shared-root and
re-created-catalog sentences move there. The admin guide's
`max_concurrent_jobs` row says that SQLite restores of items larger than
a few hundred bytes hold more and points at the manual, its backup
commands' paragraph gives the exit codes 3, 4 and 5 on a catalog `serve`
refuses, and the deployment guide's checklist has a `[backup.store]`
line. ADR-0019's Status line says it is superseded in part by the
design, whose section 10 states what that covers, a form
`docs/adr/README.md` now names; the Cassandra RFC's "Backup and restore"
section carries a note, superseded in part, since CreateBackup on
Cassandra still writes their in-catalog format, and its lines on
synchronous operations and on restored indexes carry notes too. The
differences document gives the 1M MongoDB and Cassandra restore figures.
`docs/build-docs.py` lists the manual as document 19 (the build renders
all 19), and the README's and AGENTS.md's documentation tables have a
row for it (AGENTS.md's Extending Storage row now names its file). The
quickstart and the `extenddb` skill say that `init` refuses an existing
config file without `--overwrite`.

The design's testing summary states the measured cells in place of
"still to be measured", section 7 says what a SQLite restore of items
larger than a few hundred bytes holds, the PR 11 section's line says
what shipped, and revision item 35 records the filter history, the
measurements, the manual and the database-name correction.

Co-authored-by: Lee <leeroyhannigan@yahoo.ie>
Signed-off-by: Scott Robinson <robinnsc@amazon.com>
robinnsc added a commit that referenced this pull request Nov 10, 2026
The integration workflow's PostgreSQL and SQLite jobs ran the wire suite
with `--filter "not import_export"`. The filter came with the PostgreSQL
job's first version (687e46f) and was copied into the SQLite job
(556c501); neither commit gives a reason. A foreground server wrote a
PID file in every tree up to e0d6a0a, which made foreground mode write
none by default and added `--write-pid-file` to the job in the same
commit; 556c501 came after e0d6a0a. So the restart
`devtools/run-tests` makes for the import and export tests could stop
the job's server in every tree, and the filter was not working around
it. The MongoDB and Cassandra jobs already run
`tests/test_import_export.py` unfiltered. The expression selects out
that file's ten tests and nothing else. Run the job's way on release
builds of this change they pass 10 of 10 on SQLite and on PostgreSQL,
before and after its rebase onto main 887b6e2, so both filters go and
no narrower one stays. Both lines already carry main's `--terraform`
(#474); this change removes the filter only, so each reads
`devtools/run-tests --extenddb --pytest --comprehensive --terraform
--parallel`.

`docs/design/15-backup-restore-bench-pr11.md` (row 15d of the design
index) records the cells the testing summary left open, in the PR 9
record's method: release builds, a filesystem store, the server
restarted before each phase, `VmHWM` sampled every 200 ms, on the
16-core host class of the earlier records. 1M items of 200 bytes restore
in 33.8 s on MongoDB (its own backup) and 49.0 s on Cassandra (a SQLite
backup adopted with `backup sync`), 52 and 33 MiB over idle. A 1M-item
table with a 128-dimension vector index backs up in 243 s on PostgreSQL
and 210 s on SQLite and restores in 246 s and 214 s, 111 MiB and 552 MiB
over idle; SQLite's figure is higher than at 100k under glibc's default
arenas and is 204 MiB, flat from 100k, under `MALLOC_ARENA_MAX=1`, where
the backup took 222 s and the restore 283 s. The Cassandra cells ran on
a node of their own with the Cassandra workflow's service settings. No
cell is left open. Later runs on the same host, also in the record,
reproduce the cells and show that SQLite's restore memory is its write
batch and decode chunks, not the vector index: it grows with the item's
size up to the 32 MiB batch bound whatever the attribute types (253 MiB,
130 MiB under one arena, for 100k items of 2.5 KB strings), and lists of
numbers decode larger (397 to 424 MiB for the same 100k items of 128
numbers with no index, 301 to 316 MiB under one arena for 20,000 items
of 1,536 numbers). Two restores at once under one arena took 57.5 s
against 24.9 s. Five pairs of PostgreSQL runs with and without the
vector index, each pair from one harness, put its share of the 100k
restore at 27 to 53 MiB and 33 to 47% of the duration. A MongoDB restore
becomes ACTIVE at the backfill worker's next 5 s cycle after its load,
so it takes the load's time plus up to 5 s. These figures come from
release builds of earlier versions of this change, on PR 10 at 358ff8b
and main 94b5f68, before main's later changes to the backup and restore
code (#700 and #740 as merged, and #474); the 100k cells, run again on
release builds after the rebase onto main 887b6e2, reproduce in kind
(peaks within 8.4%, durations up to 32% longer at a host load of 5.3 to
11.0 against 1.3 to 8.5 for the earlier cells).

`docs/manuals/14-backup-and-restore.md` is the operator's manual,
derived from the design: the strategy (its first sentence: a filesystem
store keeps the host's failure domain, S3 is the production
recommendation), RPO and RTO per store kind with the three records'
figures and host class (a key-ordered PostgreSQL backup also needs the
text key columns at collation `C` or `POSIX`, and the server logs a
warning when it streams an older table unordered; the vector index's
share of the SQLite restore comes from two sets of runs on a lightly
loaded host, and the record's loaded set is given and left out of the
share), the configuration (pointing at the admin guide's rows and the
store crate's README; an S3 store needs root certificates,
`ca-certificates` or `SSL_CERT_FILE`; a split-root identity mismatch is
cleared by no command in this release, since `backup purge --confirm`,
plain `backup sync` and `--prune-missing` refuse an unhealthy store, and
the manual and the deployment guide give the two remedies that exist, a
catalog copy from before the split, keeping the directory whose store id
its rows carry, or one directory's rows deleted by hand by `store_id`
from the `backup_index` table or collection (on Cassandra from
`backups_by_arn` and `backup_index_by_status`, with the rows' entries in
`backups_by_account` and `backups_by_table`), with the other directory's
account directories copied into the kept one under the drill's copy
rules before `backup sync`), securing the
store, what a running backup costs each database, a restore drill,
catalog-loss recovery with `backup sync`, `--adopt-store` and the
in-memory startup sync (the old key pairs imported once
`allow_credential_import` is turned on, with `extenddb settings` or, on
an in-memory server, the management API, and off again after), legacy
backups and what to do with them while `migrate-legacy` (#821) is not
shipped, what a restore preserves, and moving data to and from Amazon
DynamoDB with ImportTable and export (a store-prefix import is #748). It
states each deployment statement the design's PR 11 acceptance lists.
Figures measured for it, with their method in the record's "Figures
measured for the manual": a 25 s PostgreSQL backup beside 12,156
overwrites of 200-byte items grew the written table from 0.4 to 4.4 MiB,
its dead row versions not removable by a `VACUUM` during the backup (0.5
MiB with no backup); on SQLite the WAL grows by the pages each write
changes, from 4.0 to 61.1 MiB over 15,472 writes to a table with no
index during a 22.8 s backup and from 4.1 to 1,294 MiB over 13,996
writes to a table with two GSIs during a 25.6 s backup (about 20 to 24
pages per write over four runs).

The manual's process-level statements were checked on release builds of
this change before its rebase onto main 887b6e2, SQLite and PostgreSQL:
the root placement refusals and their texts, the drill, an off-host copy
under account and table directories made 0700 (a `mkdir -p` under a 022
umask stops sync until `chmod -R` on the account directory), a
re-created catalog's config file (`init --overwrite` regenerates every
section from defaults and carries over only the storage settings, so a
`port` or TLS path edited in a default section reverts too and the copy
taken first goes back whole apart from those settings) and its store
health with an explicit store and with SQLite's default root
(unconfigured, with CreateBackup writing in-catalog backups until the
adoption), the accounts re-created with their old ids and old key pairs
imported, the adoption, the in-memory startup sync and, on the in-memory
dev build, the adopted backups refused until their account is
re-created, the in-catalog create's warning and the restore of its
backup through a store-configured server, an S3 store at moto with the
default spool, `backup sync` exiting 6 beside a SQLite server,
ImportTable refusing a gzip file and both kinds of symbolic link and
importing a decompressed backup data file, an off-host copy with loose
modes refused by `backup sync`, and on PostgreSQL the claim session
found by its lock key, whose termination stops the job at its next
heartbeat and leaves the row to the reconciler, the registration
session's termination failing the server's running backups, the wait of
`--prune-missing` on a recently failed backup, a catalog restored alone
beside a newer data database, and the catalog and data dumps restored
into new databases. On PostgreSQL 16 containers the restore the admin
guide now gives ran end to end, on the old server and on a new, empty
one, and an access key was imported through the management API from a
request body read from a file. Since main's #840 the server refuses an
access key import unless `allow_credential_import` is `true`, and a
re-created catalog has no value for it: on PostgreSQL and on an
in-memory SQLite server, release builds of this tree answer the manual's
import with 403 "Credential import is disabled (allow_credential_import
= false)" and import the pair once the setting is on (`extenddb settings
set` beside the running server; on the in-memory server, which `extenddb
settings` cannot reach, `PUT
/management/settings/allow_credential_import`), and the imported pairs
keep signing requests after it is turned off. Release builds after the
rebase repeated the root placement refusals, what a restore preserves,
the drill on SQLite, PostgreSQL and an S3 store at moto, the off-host
copy shapes, a catalog restored from dumps and the claim and
registration sessions on PostgreSQL, a catalog lost and re-created on
SQLite with `--adopt-store`, the in-memory startup sync, the legacy
path, ImportTable and export, the split-root remedy by hand on SQLite,
the admin guide's Data Recovery entry on PostgreSQL 16 and `init`'s
database names.

The admin guide's Data Recovery entry named the PostgreSQL data database
`extenddb_catalog_data`; `init` names it after the catalog without its
`_catalog` suffix (`extenddb` by default). The entry now lists each
backend's databases, says a catalog name without the suffix needs
`--data-db` and that the failed `init` leaves the catalog database to
drop first, and treats the two PostgreSQL databases as one copy: both
dumps with the server stopped, under `umask 077` since the catalog dump
holds the encryption key and the application role's password, or a base
backup; the restore goes into new, empty databases created with
`createdb -O` by the admin role, since one over the existing databases
restores nothing and one into databases the admin role owns leaves the
server unable to create tables. The old databases are renamed aside
until the restored server has read every table; the dumps use the
server's major version of `pg_dump` and are checked non-empty, since an
older one exits 1 leaving an empty file that `psql` restores without an
error; and on a new server the application role is created first with
the dump's password and, at another address, the catalog's recorded
data-database address is set, or the server keeps using the old one. The
SQLite row gives the restore with the current `-wal` and `-shm` removed.
The security model and the deployment guide's checklist say the same,
and the upgrade manual's dumps take `umask 077` and are checked (`test
-s`), and its rollback renames both databases aside, restores them with
`ON_ERROR_STOP` and drops the renamed copies once the previous binary
has read every table; the checklist limits a base backup to both
databases on one instance. The architecture, design, quickstart and
security-model guides, AGENTS.md, the troubleshooting guide, the
technical-debt register (whose A-1 entry now cites functions, not moved
line numbers) and the storage-extension guide carry the right name, the
quickstart's `init` table gives the PostgreSQL admin and application
roles' flags with their defaults, and `init --help` states both database
defaults and that only the PostgreSQL backend reads the two flags. The
admin guide's `[backup]` section and the upgrade manual's backup
paragraph point at the manual; the upgrade manual's shared-root and
re-created-catalog sentences move there. The admin guide's
`max_concurrent_jobs` row says that SQLite restores of items larger than
a few hundred bytes hold more and points at the manual, its backup
commands' paragraph gives the exit codes 3, 4 and 5 on a catalog `serve`
refuses, and the deployment guide's checklist has a `[backup.store]`
line. ADR-0019's Status line says it is superseded in part by the
design, whose section 10 states what that covers, a form
`docs/adr/README.md` now names; the Cassandra RFC's "Backup and restore"
section carries a note, superseded in part, since CreateBackup on
Cassandra still writes their in-catalog format, and its lines on
synchronous operations and on restored indexes carry notes too. The
differences document gives the 1M MongoDB and Cassandra restore figures.
`docs/build-docs.py` lists the manual as document 19 (the build renders
all 19), and the README's and AGENTS.md's documentation tables have a
row for it (AGENTS.md's Extending Storage row now names its file). The
quickstart and the `extenddb` skill say that `init` refuses an existing
config file without `--overwrite`.

The design's testing summary states the measured cells in place of
"still to be measured", section 7 says what a SQLite restore of items
larger than a few hundred bytes holds, the PR 11 section's line says
what shipped, and revision item 35 records the filter history, the
measurements, the manual and the database-name correction.

Co-authored-by: Lee <leeroyhannigan@yahoo.ie>
Signed-off-by: Scott Robinson <robinnsc@amazon.com>
parsnips pushed a commit to parsnips/extenddb that referenced this pull request Nov 11, 2026
…xtendDB#855)

The integration workflow's PostgreSQL and SQLite jobs ran the wire suite
with `--filter "not import_export"`. The filter came with the PostgreSQL
job's first version (687e46f) and was copied into the SQLite job
(556c501); neither commit gives a reason. A foreground server wrote a
PID file in every tree up to e0d6a0a, which made foreground mode write
none by default and added `--write-pid-file` to the job in the same
commit; 556c501 came after e0d6a0a. So the restart
`devtools/run-tests` makes for the import and export tests could stop
the job's server in every tree, and the filter was not working around
it. The MongoDB and Cassandra jobs already run
`tests/test_import_export.py` unfiltered. The expression selects out
that file's ten tests and nothing else. Run the job's way on release
builds of this change they pass 10 of 10 on SQLite and on PostgreSQL,
before and after its rebase onto main 887b6e2, so both filters go and
no narrower one stays. Both lines already carry main's `--terraform`
(ExtendDB#474); this change removes the filter only, so each reads
`devtools/run-tests --extenddb --pytest --comprehensive --terraform
--parallel`.

`docs/design/15-backup-restore-bench-pr11.md` (row 15d of the design
index) records the cells the testing summary left open, in the PR 9
record's method: release builds, a filesystem store, the server
restarted before each phase, `VmHWM` sampled every 200 ms, on the
16-core host class of the earlier records. 1M items of 200 bytes restore
in 33.8 s on MongoDB (its own backup) and 49.0 s on Cassandra (a SQLite
backup adopted with `backup sync`), 52 and 33 MiB over idle. A 1M-item
table with a 128-dimension vector index backs up in 243 s on PostgreSQL
and 210 s on SQLite and restores in 246 s and 214 s, 111 MiB and 552 MiB
over idle; SQLite's figure is higher than at 100k under glibc's default
arenas and is 204 MiB, flat from 100k, under `MALLOC_ARENA_MAX=1`, where
the backup took 222 s and the restore 283 s. The Cassandra cells ran on
a node of their own with the Cassandra workflow's service settings. No
cell is left open. Later runs on the same host, also in the record,
reproduce the cells and show that SQLite's restore memory is its write
batch and decode chunks, not the vector index: it grows with the item's
size up to the 32 MiB batch bound whatever the attribute types (253 MiB,
130 MiB under one arena, for 100k items of 2.5 KB strings), and lists of
numbers decode larger (397 to 424 MiB for the same 100k items of 128
numbers with no index, 301 to 316 MiB under one arena for 20,000 items
of 1,536 numbers). Two restores at once under one arena took 57.5 s
against 24.9 s. Five pairs of PostgreSQL runs with and without the
vector index, each pair from one harness, put its share of the 100k
restore at 27 to 53 MiB and 33 to 47% of the duration. A MongoDB restore
becomes ACTIVE at the backfill worker's next 5 s cycle after its load,
so it takes the load's time plus up to 5 s. These figures come from
release builds of earlier versions of this change, on PR 10 at 358ff8b
and main 94b5f68, before main's later changes to the backup and restore
code (ExtendDB#700 and ExtendDB#740 as merged, and ExtendDB#474); the 100k cells, run again on
release builds after the rebase onto main 887b6e2, reproduce in kind
(peaks within 8.4%, durations up to 32% longer at a host load of 5.3 to
11.0 against 1.3 to 8.5 for the earlier cells).

`docs/manuals/14-backup-and-restore.md` is the operator's manual,
derived from the design: the strategy (its first sentence: a filesystem
store keeps the host's failure domain, S3 is the production
recommendation), RPO and RTO per store kind with the three records'
figures and host class (a key-ordered PostgreSQL backup also needs the
text key columns at collation `C` or `POSIX`, and the server logs a
warning when it streams an older table unordered; the vector index's
share of the SQLite restore comes from two sets of runs on a lightly
loaded host, and the record's loaded set is given and left out of the
share), the configuration (pointing at the admin guide's rows and the
store crate's README; an S3 store needs root certificates,
`ca-certificates` or `SSL_CERT_FILE`; a split-root identity mismatch is
cleared by no command in this release, since `backup purge --confirm`,
plain `backup sync` and `--prune-missing` refuse an unhealthy store, and
the manual and the deployment guide give the two remedies that exist, a
catalog copy from before the split, keeping the directory whose store id
its rows carry, or one directory's rows deleted by hand by `store_id`
from the `backup_index` table or collection (on Cassandra from
`backups_by_arn` and `backup_index_by_status`, with the rows' entries in
`backups_by_account` and `backups_by_table`), with the other directory's
account directories copied into the kept one under the drill's copy
rules before `backup sync`), securing the
store, what a running backup costs each database, a restore drill,
catalog-loss recovery with `backup sync`, `--adopt-store` and the
in-memory startup sync (the old key pairs imported once
`allow_credential_import` is turned on, with `extenddb settings` or, on
an in-memory server, the management API, and off again after), legacy
backups and what to do with them while `migrate-legacy` (ExtendDB#821) is not
shipped, what a restore preserves, and moving data to and from Amazon
DynamoDB with ImportTable and export (a store-prefix import is ExtendDB#748). It
states each deployment statement the design's PR 11 acceptance lists.
Figures measured for it, with their method in the record's "Figures
measured for the manual": a 25 s PostgreSQL backup beside 12,156
overwrites of 200-byte items grew the written table from 0.4 to 4.4 MiB,
its dead row versions not removable by a `VACUUM` during the backup (0.5
MiB with no backup); on SQLite the WAL grows by the pages each write
changes, from 4.0 to 61.1 MiB over 15,472 writes to a table with no
index during a 22.8 s backup and from 4.1 to 1,294 MiB over 13,996
writes to a table with two GSIs during a 25.6 s backup (about 20 to 24
pages per write over four runs).

The manual's process-level statements were checked on release builds of
this change before its rebase onto main 887b6e2, SQLite and PostgreSQL:
the root placement refusals and their texts, the drill, an off-host copy
under account and table directories made 0700 (a `mkdir -p` under a 022
umask stops sync until `chmod -R` on the account directory), a
re-created catalog's config file (`init --overwrite` regenerates every
section from defaults and carries over only the storage settings, so a
`port` or TLS path edited in a default section reverts too and the copy
taken first goes back whole apart from those settings) and its store
health with an explicit store and with SQLite's default root
(unconfigured, with CreateBackup writing in-catalog backups until the
adoption), the accounts re-created with their old ids and old key pairs
imported, the adoption, the in-memory startup sync and, on the in-memory
dev build, the adopted backups refused until their account is
re-created, the in-catalog create's warning and the restore of its
backup through a store-configured server, an S3 store at moto with the
default spool, `backup sync` exiting 6 beside a SQLite server,
ImportTable refusing a gzip file and both kinds of symbolic link and
importing a decompressed backup data file, an off-host copy with loose
modes refused by `backup sync`, and on PostgreSQL the claim session
found by its lock key, whose termination stops the job at its next
heartbeat and leaves the row to the reconciler, the registration
session's termination failing the server's running backups, the wait of
`--prune-missing` on a recently failed backup, a catalog restored alone
beside a newer data database, and the catalog and data dumps restored
into new databases. On PostgreSQL 16 containers the restore the admin
guide now gives ran end to end, on the old server and on a new, empty
one, and an access key was imported through the management API from a
request body read from a file. Since main's ExtendDB#840 the server refuses an
access key import unless `allow_credential_import` is `true`, and a
re-created catalog has no value for it: on PostgreSQL and on an
in-memory SQLite server, release builds of this tree answer the manual's
import with 403 "Credential import is disabled (allow_credential_import
= false)" and import the pair once the setting is on (`extenddb settings
set` beside the running server; on the in-memory server, which `extenddb
settings` cannot reach, `PUT
/management/settings/allow_credential_import`), and the imported pairs
keep signing requests after it is turned off. Release builds after the
rebase repeated the root placement refusals, what a restore preserves,
the drill on SQLite, PostgreSQL and an S3 store at moto, the off-host
copy shapes, a catalog restored from dumps and the claim and
registration sessions on PostgreSQL, a catalog lost and re-created on
SQLite with `--adopt-store`, the in-memory startup sync, the legacy
path, ImportTable and export, the split-root remedy by hand on SQLite,
the admin guide's Data Recovery entry on PostgreSQL 16 and `init`'s
database names.

The admin guide's Data Recovery entry named the PostgreSQL data database
`extenddb_catalog_data`; `init` names it after the catalog without its
`_catalog` suffix (`extenddb` by default). The entry now lists each
backend's databases, says a catalog name without the suffix needs
`--data-db` and that the failed `init` leaves the catalog database to
drop first, and treats the two PostgreSQL databases as one copy: both
dumps with the server stopped, under `umask 077` since the catalog dump
holds the encryption key and the application role's password, or a base
backup; the restore goes into new, empty databases created with
`createdb -O` by the admin role, since one over the existing databases
restores nothing and one into databases the admin role owns leaves the
server unable to create tables. The old databases are renamed aside
until the restored server has read every table; the dumps use the
server's major version of `pg_dump` and are checked non-empty, since an
older one exits 1 leaving an empty file that `psql` restores without an
error; and on a new server the application role is created first with
the dump's password and, at another address, the catalog's recorded
data-database address is set, or the server keeps using the old one. The
SQLite row gives the restore with the current `-wal` and `-shm` removed.
The security model and the deployment guide's checklist say the same,
and the upgrade manual's dumps take `umask 077` and are checked (`test
-s`), and its rollback renames both databases aside, restores them with
`ON_ERROR_STOP` and drops the renamed copies once the previous binary
has read every table; the checklist limits a base backup to both
databases on one instance. The architecture, design, quickstart and
security-model guides, AGENTS.md, the troubleshooting guide, the
technical-debt register (whose A-1 entry now cites functions, not moved
line numbers) and the storage-extension guide carry the right name, the
quickstart's `init` table gives the PostgreSQL admin and application
roles' flags with their defaults, and `init --help` states both database
defaults and that only the PostgreSQL backend reads the two flags. The
admin guide's `[backup]` section and the upgrade manual's backup
paragraph point at the manual; the upgrade manual's shared-root and
re-created-catalog sentences move there. The admin guide's
`max_concurrent_jobs` row says that SQLite restores of items larger than
a few hundred bytes hold more and points at the manual, its backup
commands' paragraph gives the exit codes 3, 4 and 5 on a catalog `serve`
refuses, and the deployment guide's checklist has a `[backup.store]`
line. ADR-0019's Status line says it is superseded in part by the
design, whose section 10 states what that covers, a form
`docs/adr/README.md` now names; the Cassandra RFC's "Backup and restore"
section carries a note, superseded in part, since CreateBackup on
Cassandra still writes their in-catalog format, and its lines on
synchronous operations and on restored indexes carry notes too. The
differences document gives the 1M MongoDB and Cassandra restore figures.
`docs/build-docs.py` lists the manual as document 19 (the build renders
all 19), and the README's and AGENTS.md's documentation tables have a
row for it (AGENTS.md's Extending Storage row now names its file). The
quickstart and the `extenddb` skill say that `init` refuses an existing
config file without `--overwrite`.

The design's testing summary states the measured cells in place of
"still to be measured", section 7 says what a SQLite restore of items
larger than a few hundred bytes holds, the PR 11 section's line says
what shipped, and revision item 35 records the filter history, the
measurements, the manual and the database-name correction.

Signed-off-by: Scott Robinson <robinnsc@amazon.com>
Co-authored-by: Lee <leeroyhannigan@yahoo.ie>
LeeroyHannigan added a commit that referenced this pull request Nov 14, 2026
…GSI build detached

On main, #474 starts the WarmThroughput UPDATING window of each GSI that
UpdateTable creates again before UpdateTable describes the table for its
response. Its comments give the reason as the GSI build, which UpdateTable
waited for. On this branch the build runs in a task that UpdateTable does
not wait for. The restart is still the last step before UpdateTable
describes the table, so the response still reports the window UPDATING.

The two comments in update_table.rs and the doc comment of
restart_created_gsi_warm_throughput in warm_throughput.rs now say this.
The docstring of test_gsi_create_with_warm_throughput_in_update_table said
that ExtendDB reports the table and the new index ACTIVE at once. It now
says that the table is ACTIVE and that SQLite reports the index ACTIVE. It
also says that PostgreSQL, MongoDB and Cassandra report the index CREATING
while they build it in the background. No code or assertion changes.
LeeroyHannigan added a commit that referenced this pull request Nov 18, 2026
…input

Main (#474) added the warm_throughput field to GsiInput. The CreateTableInput of the catalog_check test deployment in support.rs builds gsi1 with a GsiInput literal, which did not compile after the merge. The literal now sets warm_throughput to None, as the other PostgreSQL storage tests do, so the test creates gsi1 as before.
LeeroyHannigan added a commit that referenced this pull request Nov 20, 2026
Main added the warm_throughput field to GsiInput (#474). The GSI literal
in the multi-RANGE plan test had no value for it, and the merged tree did
not compile (E0063 at multi_range_gsi.rs:46). The literal now sets
warm_throughput to None, as the other storage tests do.
amrith pushed a commit to amrith/extenddb that referenced this pull request Nov 24, 2026
…eps live tables (ExtendDB#690)

* fix(storage-postgres): check data relations against the catalog by id

Add DiagnosticsStore::check_storage_relations and drop_orphaned_relations
with default implementations that report the backend does not support
them. The PostgreSQL store implements both from the catalog's table_id,
index_id and vector index ids through the crate's own naming functions,
so the expected names match what the engine creates. Rows in every
status count as live. The drop takes SHARE locks on tables, indexes and
vector_indexes, reads the catalog again under them, and drops only the
reported relations that no row names.

* fix(app): compare data relations with the catalog through the storage backend

catalog-check expected relations named _ddb_{account}_{table} and
_ddb_{account}_{table}__gsi__{index}, while the storage layer names them
_ddb_{table_id}, _ddb_{index_id} and _ddb_vec_{index_id}. On PostgreSQL
every live relation was reported orphaned, every live table missing, and
--fix dropped the data tables of ACTIVE tables.

Checks 1 and 2 now call the backend's DiagnosticsStore, which derives the
expected names from the catalog ids with the engine's own naming
functions and re-checks each candidate under catalog locks before it
drops it. Missing relations are reported with the table or index that
owns them. Checks 3 and 4 are unchanged.

* test(storage-postgres): cover catalog-check against the relations the engine creates

On a deployment with a separate data database, a table with a GSI, an LSI
and a vector index is neither orphaned nor missing; a planted relation no
catalog row names is dropped alone while an unrelated table and a table
created after the check are kept; a renamed index relation is reported
missing with its owner; rows in CREATING, UPDATING and DELETING count as
live. The binary is listed with the other PostgreSQL storage-level tests.

* docs: describe catalog-check and --fix for data relations without a catalog row

The troubleshooting entry told operators not to use --fix because the
command expected a different relation-naming scheme. It now describes
what the check compares, how --fix re-checks each relation under catalog
locks before dropping it, and keeps the manual comparison for inspection.

* fix(storage-postgres): wait only for index writers in catalog-check

The drop locked tables, indexes and vector_indexes in SHARE mode in one
statement and kept the locks until every drop had finished. An
UpdateTable adding a GSI on a new attribute writes indexes and then
tables, so the two could deadlock and the client got a 500. A drop
waiting on a relation another session held kept every catalog write on
the server waiting for up to 30 seconds. Under REPEATABLE READ the
re-read after the lock wait used a snapshot taken before it, and the
drop removed a live GSI relation.

Only a GSI add creates a relation before its catalog row commits, and it
holds ROW EXCLUSIVE on indexes from its insert to its end; every
relation name comes from an id generated when its row is inserted. A
SHARE lock on indexes alone therefore covers every path. It is taken in
attempts of 200 ms, 50 ms apart, within the 30 second budget, in a READ
COMMITTED transaction whose first statements take no snapshot, and it is
released right after the catalog read. Each drop then runs in its own
transaction with a 1 second lock timeout and without IF EXISTS: a
relation another session dropped first is reported as already gone, one
another session holds as failed, and no notice reaches the output.

The report waits for the index writers the same way before the catalog
read that decides orphans, and reports a relation orphaned only when a
second listing still has it. It reads the catalog a second time after
that listing and reports a relation missing only when both reads expect
it and the listing lacks it. Rows in CREATING are no longer expected to
have relations.

A catalog without data_database_connection_string, or with an empty
one, is refused again with the message the command gave before.

* test(storage-postgres): cover catalog-check against changes in flight

Split the catalog_check test binary into report, fix and support
modules, keeping its name for CI. The new tests cover a GSI add whose
relation exists and whose row has not committed, against the drop at the
default isolation and at REPEATABLE READ and against the check, with the
add's table write and another index write timed; an orphan another
session holds, with a CreateTable sent while the drop waits; a relation
another session dropped first; rows in CREATING or DELETING whose
relations are gone; a catalog without the data database setting; and a
DeleteTable, a dropped orphan and a new orphan landing between the
check's first catalog read and its second listing, held there by a
test-hooks pause.

* docs: state what catalog-check reports and drops while a server runs

The troubleshooting entry now says that the check reads the data
database's current schema and refuses a catalog without the data
database setting, that rows in CREATING are not reported missing, and
which reports can still be wrong while a server on another host changes
tables. The --fix paragraph describes the wait for GSI additions in
flight, the one second lock wait of each drop, the Already gone outcome,
and that every _ddb_ relation in the schema is taken as this
deployment's. The manual query filters on the current schema, as the
command does.

* test(storage-postgres): bound the held-orphan drop in its test

The holder session is released only after the drop returns, so a drop
without a lock timeout of its own would keep the test waiting. A 10
second timeout around the drop makes that case fail instead.

* fix(storage-postgres): lock indexes in catalog-check only for an unnamed relation

The report took the SHARE lock on indexes on every run. While that
request waits behind an open writer, every new write to indexes queues
behind it for up to one attempt, the index rows of a CreateTable
included. The check now reads the catalog first and waits for the index
writers only when a listed relation is unnamed, which outside a GSI add
in flight means a relation no row will name, so a check that finds every
relation named holds up no write. An attempt now lasts 100 ms instead of
200 ms.

* test(storage-postgres): check the catalog-check lock wait holds nothing else

The drop test against a GSI add in flight now reads pg_locks while the
drop waits for its SHARE lock on indexes, and asserts that the waiting
session holds no lock on tables or vector_indexes. Before, a lock of all
three tables passed the test: each attempt's 100 ms lock timeout ends
the wait before PostgreSQL's deadlock check runs, so the add's table
write still finished in time.

* test(storage-postgres): commit the GSI add while catalog-check waits

The drop test committed the add after a fixed 600 ms, which fell in the
50 ms pause between two lock attempts about a third of the time. The next
attempt then started after the commit, and a snapshot taken before the
lock still saw the row, so the REPEATABLE READ case passed without the
isolation fix. The test now commits only once pg_locks shows a SHARE
request on indexes that began less than 20 ms earlier, so the commit
lands while that attempt waits.

* docs: state that catalog-check waits for index writers only when needed

The troubleshooting entry still said the check always waits for the GSI
additions in flight and that each lock attempt lasts 200 ms. The check
waits only when it finds a relation no row names, and an attempt lasts
100 ms. A write to indexes that queues behind the granted lock also
waits for the one catalog read the lock is held for; the entry and the
comment on the attempt length now say so.

* docs: drop the count from the catalog-check wrong-report sentence

The troubleshooting entry opened its list of the reports that can be
wrong while a server runs with a count of them. It now states the
condition and lists them.

* fix(app): open the encrypted connection string row in catalog-check

Main (ExtendDB#1003) encrypts the data_database_connection_string row of a PostgreSQL catalog with a key ring under the ring's DEK. Main's catalog-check read the row and opened it in data_connection_text. Without a ring the command takes the row as stored. With a ring the KEK of [auth.encryption] key_file opens it, and the command refuses a ring when key_file is not set. test_data_database_connection takes the key and reads the row through data_connection_string, with the same rules.

This branch reads the row in the PostgreSQL store, in data_pool, for check_storage_relations and drop_orphaned_relations. The plain read gave ciphertext in a catalog with a ring. The two methods now take the key as test_data_database_connection does. data_pool reads the row through data_connection_string with that key. catalog-check passes the key source of [auth.encryption] (the KEK with key_file set, else the catalog key). data_connection_text has no caller now, so the commit deletes it. A missing or empty row in a catalog without a ring still gets the message of this branch. The catalog_check tests pass the catalog key, as the command does without key_file.

* test(storage-postgres): set warm_throughput in the catalog_check GSI input

Main (ExtendDB#474) added the warm_throughput field to GsiInput. The CreateTableInput of the catalog_check test deployment in support.rs builds gsi1 with a GsiInput literal, which did not compile after the merge. The literal now sets warm_throughput to None, as the other PostgreSQL storage tests do, so the test creates gsi1 as before.

* fix(app): set up the locked key store before catalog-check reads the KEK

catalog-check read the KEK of [auth.encryption] key_file with key_file::key_source and did not set up the locked key store first. The DEK that the KEK unwraps was then held in heap memory. verify and migrate read the KEK through util::status_key_source, which sets up the locked key store before the read, and catalog-check now uses that helper too. With key_file set, on a host where memory locking fails and require_locked_memory is true, catalog-check now refuses to run, as verify and migrate do there.

* test(storage-postgres): run the catalog-check relation check on a catalog with a key ring

No test ran check_storage_relations on a catalog whose data database connection string row is encrypted under the DEK of the key ring. set_data_connection_writes_the_row_under_the_ring now runs it after set_data_connection writes the row. With the KEK the check opens the row, and with the catalog key it returns an error.

* docs: state the DeleteTable order of main's ExtendDB#504 in the catalog-check texts

On a separate data database, main's ExtendDB#504 keeps the catalog row of a table DELETING until the drop of its data tables commits. It deletes the row after that drop. The catalog-check texts of this branch still said that a synchronous DeleteTable deletes the row before its drop. The lists of orphan reports in catalog_check.rs and troubleshooting.md no longer name that case, and troubleshooting.md no longer names a table among them. The example of a relation that another session drops first is now an UpdateTable that deleted a GSI. That change is in diagnostics.rs, in the fix test and in troubleshooting.md. The description of the report test no longer gives the old order.

* test(storage-postgres): fail the catalog_check tests when a job needs a server and has none

The catalog_check tests skipped when EXTENDDB_TEST_PG_CONNECTION_STRING was not set, also with EXTENDDB_TEST_PG_REQUIRED=1. With that setting and no connection string, all 13 tests passed. base_conn in tests/catalog_check/support.rs now makes the check that iam_leftovers.rs and stream_commit_order.rs make. When EXTENDDB_TEST_PG_REQUIRED has a value other than 0 and the connection string is not set, the test fails. The comment at integration.yml:772 gives this behaviour for every test of the crate.

* test(storage-postgres): create pgvector in the catalog_check data database

Deployment::new in tests/catalog_check/support.rs did not create the pgvector extension in the data database. Neither create_data_db nor migrations::migrate runs CREATE EXTENSION vector, and template1 of the pgvector/pgvector:pg16 image has only plpgsql. So pgvector() was false on both CI images and no test created vec1. With named_relations changed to name no vector index relation, all 13 tests passed.

Deployment::new now calls try_create_vector_extension on the data database. The run-postgres-storage-tests job sets EXTENDDB_EXPECT_VECTORS=1, and with that setting Deployment::new fails when the data database has no pgvector. Now 8 of the 13 tests fail with that change.

* test(storage-postgres): cover the end of the catalog-check index lock budget

No test reached the end of the 30 second wait for the index writers in flight. All tests passed without the deadline check in read_after_index_writers, and also without the budget message in catalog_check_error.

PostgresCatalogStore now keeps the budget in a field that new and with_secret_keys set to INDEX_LOCK_BUDGET. with_index_lock_budget, compiled only with test-hooks, makes a store with a shorter budget. The new test holds ROW EXCLUSIVE on indexes past a budget of 2 seconds. Then it asserts the error of the check and of the drop, and that the orphan is still there. Without the deadline check the test fails at its 10 second timeout. Without the budget message it fails on the error text.

* fix(storage-postgres): give the catalog-check index lock text only for the indexes lock

catalog_check_error gave the text "index changes in progress kept the index catalog locked for more than 30 seconds" for each error that lock_wait_failed accepts. Those are SQLSTATE 55P03, 40P01 and 57014. A 55P03 from read_catalog can come from a lock on tables or vector_indexes. With statement_timeout=50ms on the catalog sessions, the check gave that text after the first lock attempt. With ACCESS EXCLUSIVE held on vector_indexes and no index change in flight, it gave that text when the budget ran out.

check and drop_orphaned now return a CheckFailure. read_after_index_writers gives CheckFailure::IndexLock when the last attempt timed out on the SHARE lock on indexes after the deadline. Every other error is CheckFailure::Sql, and catalog_check_error gives its text unchanged. A new test runs both cases, and the store gives the server's own error in each.

* fix(storage-postgres): list the data relations that the search path reaches in catalog-check

storage_relations listed the relations in current_schema() only. The server and the drop resolve unqualified names through the search_path. With search_path = alt, public set for the role on the data database, the server kept serving the table in public. The check then reported its relations missing, because current_schema() was alt. A listing of every schema also passed all tests.

The listing now reads pg_class and keeps the relations for which pg_table_is_visible is true, which resolves names as the server's statements and the drop do. The new test sets that search path and plants a relation with the prefix in a schema off the path. It checks that nothing is missing or orphaned. Without the fix the test reports the 4 relations of the table missing. Without the visibility filter it reports the planted relation orphaned. troubleshooting.md now gives that scope, and its query by hand uses the same filter.

* fix(storage-postgres): refuse a key ring row that the key does not open as not configured

data_pool mapped every error of data_connection_string to DiagError::QueryFailed. Without the KEK, catalog-check refused a catalog with a key ring. It printed "Cannot compare data relations with the catalog: Query failed: the catalog has a key ring, ...". No query failed. data_pool now maps MigrationError::Refused to DiagError::NotConfigured, as for the absent setting. catalog-check then prints the refusal on its own, as it did before the check moved to the storage backend.

In key_ring_rows.rs, the check without the KEK passed on any error, also on a connection failure. It now asserts NotConfigured with the start of the refusal text. At the previous commit that assertion fails with the QueryFailed error.

* docs: state the catalog-check report stop after 30 seconds and the wait of each indexes write

troubleshooting.md gave the outcome of a wait for index writers that runs past 30 seconds for --fix only. The report without --fix stops there too. It prints the error that says so and no result of any check, and exits with status 1. The paragraph on the check now says so.

The paragraph on --fix said that a server's write to indexes waits at most 100 ms plus the one catalog read. That bound holds for each write. One CreateTable with a GSI writes indexes more than once and can wait that long at each write. The paragraph now says "Each write to indexes" and names that case.

The sentences that the search path commit changed in the same section are now split into shorter ones. The lead-in to the query by hand now says that the query lists the relations that no catalog id names, which is what it returns.

* test(app): run catalog-check as the binary against a PostgreSQL deployment

No test covered cmd_catalog_check.rs, and no workflow ran catalog-check against PostgreSQL. The store tests stop at PostgresCatalogStore. So nothing tested the call of status_key_source, the mapping of NotConfigured, the lines the command prints or its exit code.

crates/bin/tests/catalog_check.rs runs the extenddb binary on the deployment of the catalog_check storage tests, through their support module. The deployment has one orphaned relation and one missing GSI relation. The test asserts the whole output and exit status 1 of catalog-check --fix and of the report without --fix. Then it removes the data database setting and asserts the refusal alone on stderr. With the NotConfigured message prefixed as the other errors are, the test fails on that last line. The run-postgres-storage-tests job runs the test with EXTENDDB_TEST_PG_REQUIRED=1. The bin crate gets dev-dependencies on extenddb-core and on extenddb-storage-postgres with test-hooks, which exports the naming functions that the support module uses.

* fix(storage-postgres): turn off statement logging on the diagnostics store's catalog pool

The diagnostics store connected to the catalog with statement logging on. A catalog read that waited on a lock for more than 1 second then printed a slow statement line. That line held the full CATALOG_ROWS text and came between the lines of the catalog-check report. The binary writes its log to stdout. The diagnostics store factory now connects with disable_statement_logging, as data_pool does for the data database.

In the catalog-check binary test, the report without --fix now runs while another session holds ACCESS EXCLUSIVE on vector_indexes for 1.5 seconds. At the previous commit, the output then has a line "WARN sqlx::query: slow statement: execution time exceeded alert threshold". The line comes after "Connected to catalog.", and the test fails. With this change the output has no log line.

* style: format the catalog-check tests with rustfmt

The rustfmt check of fmt.yml reported four test files that the earlier commits of this round changed: crates/bin/tests/catalog_check.rs, and fix.rs, support.rs and key_ring_rows.rs under crates/storage-postgres/tests. This commit applies cargo fmt to them. No code changes.

* test(storage-postgres): check pgvector on the built catalog_check deployment

Deployment::new checked the pgvector setting before it built the Deployment. When the check failed, Drop did not run and the two scratch databases stayed on the server. The check now runs on the built Deployment through pgvector(), so a failure drops the databases as any other test failure does.

* test(storage-postgres): run the drop in the catalog-check failure test too

No test covered the locked flag in read_after_index_writers. Row 2 of other_catalog_failures_do_not_report_index_changes holds ACCESS EXCLUSIVE on vector_indexes. The check stops in read_catalog there, before it requests any lock on indexes. The drop calls read_after_index_writers at once. So its read under the SHARE lock is the path that the flag guards.

Each row of the test now also runs drop_orphaned_relations on the planted orphan and asserts the same error text as for the check. With the flag removed from the IndexLock arm, the test fails on row 2's drop. That drop then gives the text "index changes in progress kept the index catalog locked for more than 2 seconds, so nothing was dropped".

* docs: drop the catalog-check sentence on waits at each indexes write

troubleshooting.md said that a request can write indexes more than once, as a CreateTable with a GSI does. It said that such a request can then wait behind the command at each write. A CreateTable inserts all its indexes rows in one catalog transaction (create_table.rs, from the begin at line 161 to the commit at line 555). PostgreSQL does not make a transaction wait again for a lock that it holds already. So a CreateTable waits on the command once. This commit deletes that sentence. The sentence before it stays: each write to indexes waits behind the command for at most 100 ms plus the one catalog read.

* test: one helper for the catalog-check sessions that hold a lock

Four places in the catalog-check tests opened a session, ran BEGIN and then ran one lock statement. These were hold_relation in support.rs, the budget test in fix.rs, the failure test in report.rs and the binary test. support.rs now has one helper, hold(url, statement), that does this and returns the session. hold_relation and the three tests use it.

* refactor(storage-postgres): map the diagnostics store's connect errors once

The diagnostics store factory mapped the parse error and the connect error to ConnectionFailed with two identical closures. It now parses and connects in one async block and maps the block's error once.

* ci: set the PostgreSQL test settings once for the storage test job

Both test steps of run-postgres-storage-tests set EXTENDDB_TEST_PG_CONNECTION_STRING, EXTENDDB_TEST_PG_REQUIRED and EXTENDDB_EXPECT_VECTORS to the same values. The job's env now sets them once, with the comments that the first step had.

* refactor(storage-postgres): drop the unused Debug derive of CheckFailure

Nothing formats a CheckFailure with {:?}. catalog_check_error matches on it, and no caller unwraps a Result that holds one. This commit removes the derive.

* test(storage-postgres): use the hold helper in the open index write test

a_check_that_finds_every_relation_named_does_not_wait_for_index_writers
opened a catalog session, began a transaction and ran its UPDATE of
indexes inline. The hold helper in the support module does the same, so
the test now calls it.

* test(storage-postgres): check an ACTIVE index of a settling table in catalog-check

CreateTable inserts the GSI, LSI and vector index rows ACTIVE under a
table row that can be CREATING. DeleteTable leaves them ACTIVE under a
DELETING table row. named_relations expects an index relation only when
neither the index row nor its table row is CREATING or DELETING. No test
covered the table half: with "table_settled &&" removed from the index
rows, all 16 catalog_check tests passed.

rows_being_created_or_deleted_are_not_reported_missing now sets the
index and vector index rows back to ACTIVE before it moves the table to
DELETING and CREATING. With "table_settled &&" removed, the test fails
with the gsi1, lsi1 and vec1 relations reported missing.

* refactor(storage-postgres): classify undefined_table beside lock_not_available

The catalog-check drop compared the SQLSTATE of its error with its own
42P01 constant, through a copy of the sqlstate function of
migrations/connect.rs. data/ddl.rs already classifies lock_not_available
with sqlstate_is. It now has undefined_table beside it, and the drop
calls that. catalog_check.rs no longer has the constant or the copy.

* refactor(storage-postgres): share the data database read and connect of the diagnostics store

data_pool repeated three steps of test_data_database_connection: the
PostgresTarget for the catalog, the data_connection_string read and the
pool connect. data_connection_row and connect_data now do them for both.
Each caller keeps its own errors: test_data_database_connection reports
a failed read as "Query failed", and data_pool reports a refused row as
not configured.

The connect of test_data_database_connection now has the options of the
data_pool connect: two connections at most and statement logging off. It
opens one connection and runs no statement on it, so extenddb verify
prints the same lines.

* test(storage-postgres): assert the full catalog-check messages

Four asserts of the catalog-check tests compared only the start or the
end of a message. One is the key ring refusal in key_ring_rows.rs. Three
are in catalog_check/fix.rs: the Kept reason of a later table, the lock
text of a held orphan and the index lock budget text. Each message has a
fixed text, so each assert now compares the whole text.

* test(app): remove the catalog-check config directory when the test fails

The binary test removed its config directory only after its last
assert, so a failed run left the directory under CARGO_TARGET_TMPDIR.
A ConfigDir guard now removes it on drop, as Deployment drops its
databases.

* docs: say catalog-check waits for the index changes in flight

The troubleshooting entry said that the check and --fix wait for the
GSI additions in flight. The SHARE lock on indexes waits for every open
write to indexes, and the error text says "index changes in progress".
The entry now says "index changes in flight".

* style: put PostgreSQL and GetItem in backticks in the catalog-check docs

clippy::pedantic gave doc_markdown warnings on five doc comment lines
that this branch adds: four name PostgreSQL and one names GetItem. The
names are now in backticks, and the pedantic run of the touched crates
gives no warning on a line of this branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-blocker Must ship for its milestone's release v1 Needed for the 1.0 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DescribeTable omits WarmThroughput; Terraform AWS provider 6.13.0 and later hangs on every table apply

4 participants