Repository navigation
fix: match data relations by catalog id in catalog-check, so --fix keeps live tables - #690
Merged
Merged
Conversation
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.
… 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.
… 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.
…atalog 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.
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.
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.
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.
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.
…med 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.
…ng 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.
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.
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.
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.
LeeroyHannigan
requested review from
amrith,
c33howard,
jcshepherd,
pdf-amzn,
robinnsc and
yesyayen
as code owners
October 31, 2026 11:48
4 of 8 tasks
.github/workflows/integration.yml conflicted. Main runs every test target of extenddb-storage-postgres with --tests, so the step keeps main's command and this branch's comment line on the catalog_check test. Main replaced PostgresBootstrapper::run_catalog_migrations and run_data_migrations with the migration runner. The catalog_check test support now runs extenddb_storage_postgres::migrations::migrate on the catalog and data databases, as main's migrate_data_db_name test does. It sets the two delay settings with an upsert, as main's PostgreSQL tests do, so each row exists whether or not a migration seeds it.
LeeroyHannigan
requested review from
eliseong,
hitesh96db and
navareamol
as code owners
November 5, 2026 01:30
8 tasks done
crates/app/src/cmd_catalog_check.rs keeps the comparison through the storage backend from this branch in place of the direct read of the data database by main (#1003). It keeps main's data_connection_text below the command. crates/storage/src/diagnostics.rs keeps the key argument of test_data_database_connection from main and the check_storage_relations and drop_orphaned_relations methods from this branch.
LeeroyHannigan
added a commit
that referenced
this pull request
Nov 24, 2026
Main is at 018715e, three commits after the last merge (#690, #765 and #774). One file conflicted: the docstring of tests/test_expression_param_usage.py. #765 states that the values message of a Scan or a Query whose AttributeValues parse has no suffix. This branch adds the wrapped messages of the single-item writes. The merge keeps both statements. #765 also passes no expression parameters to the values check in handle_scan, which merged clean. So the row of tests/test_expression_semantics.py that sends a Scan with a ProjectionExpression and ExpressionAttributeValues now expects the message with no suffix. The service answered that request with the same message, on a table that does not exist, on 24 November 2026, each request sent twice.
This was referenced Nov 24, 2026
LeeroyHannigan
added a commit
that referenced
this pull request
Nov 24, 2026
Main is at 89fc971, four commits after the last merge (#690, #765, #774 and #1280). One file conflicted: the docstring of tests/test_expression_param_usage.py. #765 states that the values message of a Scan or a Query whose AttributeValues parse has no suffix. This branch adds the wrapped messages of the single-item writes. The merge keeps both statements. #765 also passes no expression parameters to the values check in handle_scan, which merged clean. So the row of tests/test_expression_semantics.py that sends a Scan with a ProjectionExpression and ExpressionAttributeValues now expects the message with no suffix. The service answered that request with the same message, on a table that does not exist, on 24 November 2026, each request sent twice.
LeeroyHannigan
added a commit
that referenced
this pull request
Nov 24, 2026
Main is at 018715e, 5 commits after the last merge (#503, #526, #690, #765 and #774). No file has a conflict. One file changed on both sides, and git merged it with no overlap: docs/differences-from-dynamodb.md. #526 adds a Transactions section to it, and this branch changes the index key validation row. #526 puts the Return fields in the token fingerprint and gives IdempotentParameterMismatchException the service's message. #774 picks the message key per error. The commits after this merge bring the branch in line with both.
6 of 8 tasks
LeeroyHannigan
added a commit
that referenced
this pull request
Nov 24, 2026
Merges main at 018715e, five commits past 6aef346: - #503: the stream retention cutoff shape on SQLite - #526: the Return fields on a TransactWriteItems token replay - #690: catalog-check matches data relations by catalog id - #765: the FilterExpression suffix in the values message - #774: the Message key on two errors No conflicts. None of the five changes a file of this branch. #774 changes crates/server/src/response.rs, which renders the errors this branch's tests assert. The key on SerializationException stays message.
LeeroyHannigan
added a commit
that referenced
this pull request
Nov 24, 2026
Merges b9baaf5 of fix/request-nesting-depth. That commit merges main at 018715e into the other branch, five commits past 6aef346: - #503: the stream retention cutoff shape on SQLite - #526: the Return fields on a TransactWriteItems token replay - #690: catalog-check matches data relations by catalog id - #765: the FilterExpression suffix in the values message - #774: the Message key on two errors No conflicts. None of the five changes a file of this branch. #774 changes crates/server/src/response.rs, which renders the refusals that this branch's tests assert. SerializationException keeps the message key, and a refusal with an empty message still has no message key.
LeeroyHannigan
added a commit
that referenced
this pull request
Nov 24, 2026
Merges 0986467 of fix/1195-syntax-fault-message, its merge of fix/request-nesting-depth at b9baaf5. That commit merges main at 018715e, five commits past 6aef346: - #503: the stream retention cutoff shape on SQLite - #526: the Return fields on a TransactWriteItems token replay - #690: catalog-check matches data relations by catalog id - #765: the FilterExpression suffix in the values message - #774: the Message key on two errors No conflicts. None of the five changes a file of this branch. #774 changes crates/server/src/response.rs, which renders the refusals that this branch's tests assert. SerializationException keeps the message key, and a refusal with an empty message still has no message key.
LeeroyHannigan
added a commit
that referenced
this pull request
Nov 24, 2026
Merges 0986467 of fix/1195-syntax-fault-message, its merge of fix/request-nesting-depth at b9baaf5. That commit merges main at 018715e, five commits past 6aef346: - #503: the stream retention cutoff shape on SQLite - #526: the Return fields on a TransactWriteItems token replay - #690: catalog-check matches data relations by catalog id - #765: the FilterExpression suffix in the values message - #774: the Message key on two errors No conflicts. None of the five changes a file of this branch. #774 changes crates/server/src/response.rs, which renders the refusals and the authentication errors that this branch's tests assert. The two errors that get the Message key are not among them. A refusal with an empty message still has no message key.
LeeroyHannigan
added a commit
that referenced
this pull request
Nov 24, 2026
Merges 54ed1f2 of fix/1257-leading-zero-numbers, its merge of fix/1195-syntax-fault-message at 0986467. That brings in fix/request-nesting-depth at b9baaf5, which merges main at 018715e, five commits past 6aef346: - #503: the stream retention cutoff shape on SQLite - #526: the Return fields on a TransactWriteItems token replay - #690: catalog-check matches data relations by catalog id - #765: the FilterExpression suffix in the values message - #774: the Message key on two errors No conflicts. None of the five changes a file of this branch. #774 changes crates/server/src/response.rs, which renders the refusals that this branch's tests assert. SerializationException keeps the message key, and a refusal with an empty message still has no message key.
This was referenced Nov 24, 2026
LeeroyHannigan
added a commit
that referenced
this pull request
Nov 24, 2026
No conflicts. Main (#690, #765, #774) changed two of the files this branch touches, in lines this branch does not change. It adds an undefined_table helper in crates/storage-postgres/src/data/ddl.rs, and it changes the diagnostics store connection and adds a test-hooks re-export in crates/storage-postgres/src/lib.rs.
LeeroyHannigan
added a commit
that referenced
this pull request
Nov 24, 2026
Main is at 018715e, seven commits after the last merge (#432, #468, #503, #526, #690, #765 and #774). One file conflicted: crates/storage-postgres/src/data/mod.rs. #690 adds STORAGE_RELATION_PREFIX where this branch imports from_catalog_json and to_catalog_json. The merge keeps both. Main changed seven other files this branch changes, and git merged them with no overlap. The PostgreSQL query and query_scan modules keep this branch's import of parse_sk and pk_to_text from data::key_text. So the LSI index walk of #432 refuses a key that holds U+0000 as the other reads do. The AT_TIMESTAMP seek of #468 reads sequence numbers only, so the record escape does not apply to it. Main adds no catalog migration, so migration 13 keeps its number.
6 of 8 tasks
LeeroyHannigan
added a commit
that referenced
this pull request
Nov 25, 2026
crates/storage-postgres/src/lib.rs conflicted in its test-hook exports. Main's #690 added the export of catalog_check::test_pause, and this branch added the exports of GSI_BUILD_SLOTS and hold_gsi_backfill_for_tests at the same place. The merge keeps the three exports, in path order. The other files merged without a conflict.
6 of 8 tasks
robinnsc
added a commit
that referenced
this pull request
Nov 26, 2026
Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has two features (#468, #1009) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #503, #544, #567, #765 and #774, #588, #596, #690, #1144, #1173 and #1194, next to the existing entries for #398 and #526. The #526 entry now gives the old TransactWriteItems mismatch message, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone. Signed-off-by: Scott Robinson <robinnsc@amazon.com>
robinnsc
added a commit
that referenced
this pull request
Nov 26, 2026
Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has two features (#468, #1009) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194 and #1375, next to the existing entries for #398, #526 and #1166. The #526 entry now gives the old TransactWriteItems mismatch message, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone.
robinnsc
added a commit
that referenced
this pull request
Nov 27, 2026
Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has three features (#468, #1009, #1449) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194, #1375 and #1522, next to the existing entries for #398, #526, #1166, #1449 and #1523. The #526 entry now gives the old TransactWriteItems mismatch message, the #1523 heading takes the v1.1.0: prefix, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone.
robinnsc
added a commit
that referenced
this pull request
Nov 27, 2026
Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has three features (#468, #1009, #1449) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194, #1375 and #1522, next to the existing entries for #398, #526, #1166, #1449 and #1523. The #526 entry now gives the old TransactWriteItems mismatch message, the #1523 heading takes the v1.1.0: prefix, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone. docs/troubleshooting.md: the bus error entry names 1.0.0 as the release that has the bug, so its line carries a version-literal-ok marker.
LeeroyHannigan
added a commit
that referenced
this pull request
Nov 27, 2026
* chore(release): bump version to 1.1.0 Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has three features (#468, #1009, #1449) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194, #1375 and #1522, next to the existing entries for #398, #526, #1166, #1449 and #1523. The #526 entry now gives the old TransactWriteItems mismatch message, the #1523 heading takes the v1.1.0: prefix, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone. docs/troubleshooting.md: the bus error entry names 1.0.0 as the release that has the bug, so its line carries a version-literal-ok marker. * docs(upgrade): add the v1.1.0 entry of #1290, put #1349's in order #1290 merged after this branch was rebased. It changes the answer to a request with no Authorization header, so it gets a v1.1.0 entry. The merge of main put the #1349 entry after the #1523 entry. It moves to the place of its number, beside the new #1290 entry. --------- Co-authored-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes since the last review
demohan reviewed
62787ee78on 19 November. The section "Changes after the 19 November review" below lists the fixes for that review, up to4c1818682. The commits after4c1818682:7309bc737mergesmainat1d3be632f. No file conflicted.5e36eaafb:rows_being_created_or_deleted_are_not_reported_missingsets the index and vector index rows back to ACTIVE before it moves the table to DELETING and CREATING. CreateTable inserts the index rows ACTIVE under a table row that can be CREATING, and DeleteTable leaves them ACTIVE. Withtable_settled &&removed from theexpectedof the index rows, all 16 tests passed before this commit. Now this test fails, with the gsi1, lsi1 and vec1 relations reported missing.59b48d4b4: the drop classifies SQLSTATE 42P01 withundefined_tableindata/ddl.rs, besidelock_not_available.catalog_check.rsno longer has its own 42P01 constant or its copy ofsqlstate. The drop keeps its ownSET LOCAL lock_timeout.set_lock_timeout_untilindata/ddl.rssets the time left to a deadline, so a 1 s deadline gives 999 ms or less. The drop's error text says more than 1000 ms.9754d3a1f:data_poolandtest_data_database_connectionshare two helpers.data_connection_rowreads the connection string row as the server reads it, andconnect_dataconnects to the data database. Each caller keeps its own errors. The data database check ofverifynow connects with the options of thecatalog-checkdata pool: two connections at most and statement logging off. It runs no statement on that pool.ea52779a1: four asserts compare the whole message. One is the key ring refusal inkey_ring_rows.rs. Three are incatalog_check/fix.rs: theKeptreason, the held relation text and the budget text.b8dca1a73: the binary test removes its config directory in aDropguard, so a failed run does not leave the directory underCARGO_TARGET_TMPDIR.66b97c411: the troubleshooting entry says "index changes in flight" in place of "GSI additions in flight", because the lock waits for every open write toindexes.75c9a06c9: five doc comments of this branch putPostgreSQLandGetItemin backticks. The pedantic clippy run then gives no warning on a line of this branch.75c9a06c9. The loop section names the production changes after90d429449. A new section lists the conflicts with fix(storage-postgres): return UpdateTable before the GSI backfill finishes #708, fix(storage): store U+0000 in strings on PostgreSQL and MongoDB #368 and feat: add StartBulkPutItems and the bulk operation APIs #874 and their resolutions.What
The relation names belong to the storage backend, so the comparison moved there.
DiagnosticsStore(crateextenddb-storage) gainscheck_storage_relations(key)anddrop_orphaned_relations(key, orphaned), with defaults that report the backend does not support them.keyis the key thattest_data_database_connectiontakes. On PostgreSQL it opens the encrypted connection string row of a catalog with a key ring. Other backends are untouched.data/catalog_check.rs. Expected names come fromtable_storage_relations, the listDeleteTabledrops, for the rows oftables,indexesandvector_indexesin any status, through the crate's own naming functions. The data relations are listed frompg_classby the_ddb_prefix the naming functions now share. The listing keeps the relations that unqualified names reach on the data database (pg_table_is_visible), which is how the server and the drop resolve them.indexesto end. Then it reads the catalog again before it compares (see the lock section below). A check that finds each listed relation named takes no lock. If the index changes in flight do not finish within 30 s, the command prints an error that says so and exits with status 1. No check prints a result then.--fixwaits for theindexeswriters the same way, reads the catalog under that lock, and releases the lock before it drops anything. Then the command drops each reported relation that the read does not name, withDROP TABLEwithoutIF EXISTS. Each drop runs in a transaction of its own with a lock timeout of 1 s. That is the bound thatSYNC_DROP_LOCK_TIMEOUTsets for the server's own synchronous drops. The command printsDropped, orAlready gonewhen another session dropped the relation first (SQLSTATE 42P01). It printsKeptwith the reason, orFAILEDwith the error. For a relation another session holds longer than 1 s, the error readsanother session held a lock on it for more than 1000 ms, so it was kept; run the command again. If the index writers do not finish within 30 s, the command reports that, drops nothing and says to run it again.data_database_connection_string, or with an empty value, is refused. Without a key ring the message is "No data database connection string in settings. Runextenddb init." With a ring it is the refusal of the server, which namesextenddb encryption-key set-data-connection. Both store methods refuse it, so the command does not look for data relations in the catalog's own database. The data pool and the diagnostics store's catalog pool connect with statement logging off. A read or a drop that waits on a lock then adds no slow-statement line to the report.extenddb verifygets its diagnostics store from the same factory, so on PostgreSQL it no longer prints slow-statement lines for its reads through that store either.data_connection_string, the reader that the data database check ofverifyuses, with the key that the command passes. That key is the KEK of[auth.encryption] key_filewhen it is set, else the catalog key, which opens no such row. A catalog with a ring and nokey_fileis therefore refused before the command connects to the data database. Withkey_fileset, the command sets up the locked key store and reads the KEK file before it reads the catalog, asserveandverifydo. A KEK file that the file rule refuses then stops the command on a catalog without a ring too.cmd_catalog_check.rscalls the store for checks 1 and 2 and reports each missing relation with the table or index that owns it. The command no longer prints "Connected to data database.". It prints "Compared data relations with the catalog." after the comparison. Checks 3 and 4, the PID refusal, the counting and the exit code are unchanged.docs/troubleshooting.md: the entry from feat(storage): SnapshotEngine, a consistent table snapshot on every backend [backup/restore 4/4] #395 told operators not to use--fix. It now describes the check, what it waits for, the reports that can be wrong while a server runs (below) and the drop outcomes. It says that--fixtreats each_ddb_relation that unqualified names reach on the data database as this deployment's, and its manual query uses the same filter.The lock on
indexesEach relation name comes from a UUID that the request inserting its catalog row generates for that row. For a table and the GSIs, LSIs and vector indexes created with it, that request is in
create_table.rs, which restore also uses. For a GSI or vector index added later, it is inupdate_table.rs. No path inserts a row for an id it did not generate, so a row inserted later cannot name a relation that exists already. The recovery paths ingsi_build.rsandvector_index.rscreate a relation only for a row that has committed.CreateTable and a vector index add commit the catalog rows first and create the relations after. A GSI add in
UpdateTableis the only path that commits its relation before its row. It inserts the index row, creates and commits the relation on the data database, and then commits the catalog transaction. That transaction holds ROW EXCLUSIVE onindexesfrom the insert to its end. A SHARE lock onindexesis granted only after each such add whose relation exists has committed or rolled back. A catalog read taken after the grant sees the rows of those that committed. No row names a relation that this read does not name, and no row inserted later can name it.The command requests the lock in attempts of 100 ms, 50 ms apart, for up to 30 s. While an attempt waits, new writes to
indexesqueue behind it. A server write therefore waits on the command for at most 100 ms plus the one catalog read that the lock is held for. The command holds no other lock while it waits, so it cannot take part in a deadlock. The next statement of the GSI add, an update of itstablesrow, does not wait on the command. The transaction runs at READ COMMITTED whateverdefault_transaction_isolationthe database, role or connection sets. It sets its lock timeout withSET LOCAL, which takes no snapshot, so the read after the grant sees rows committed during the wait.Servers do not hold
migrate's advisory lock, so taking it would not exclude a running CreateTable or UpdateTable.#708 (
fix/654-pg-async-gsi-build), the fix for #654, stopsUpdateTablefrom waiting for the GSI build. It leaves the order of insert, create and commit of the add as it is, so the lock covers a GSI add there too. Its cleanup of a failed build removes the CREATING row, waitsGRACE_PUBLISH(1 s) and then drops the relation, in the order that main uses. A check in that second therefore reports the relation orphaned. The conflict of the two branches is under "Conflicts with other open PRs" below.Reports that can be wrong while a server runs
The command refuses to run while it finds the server's PID file. It does not see a server started without
--write-pid-file, one on another host, or one using anotherrun_diror port. With a server running, the reports below can be wrong, and a later run does not repeat them:GRACE_PUBLISHsecond. A synchronous DeleteTable keeps its row DELETING until its data tables drop (fix(postgres): keep a deleted table DELETING until its data tables drop #504), so its relations stay named. A--fixthat drops such a relation first causes the server no error, because the server's drops useIF EXISTS.control_plane_delay_secondsis 0. Otherwise the row moves from CREATING to ACTIVE once that delay (0.25 s by default) has passed since its catalog transaction began. It moves whether or not the relations have committed.--fixdrops only relations reported orphaned, so a wrong missing report leads to no drop.The command does not report a GSI or vector index stuck in CREATING. Check 4 covers tables only, and check 2 does not count a CREATING index row as expected.
Why
extenddb catalog-checkexpected data relations named_ddb_{account}_{table}and_ddb_{account}_{table}__gsi__{index}. The storage layer names them from catalog ids:_ddb_{table_id},_ddb_{index_id}and_ddb_vec_{index_id}for vector indexes, which the command did not know. It also counted only tables in ACTIVE or CREATING as live.This was measured on main
1c0523c90on 2026-10-30, against PostgreSQL 16 with pgvector and a separate data database asextenddb initcreates it. The deployment had one table with a GSI, an LSI and a vector index. The report listed all four live relations as orphaned and three names that never existed as missing.--fixdropped the four relations. GetItem then returnedResourceNotFoundException, and Query on either index returnedValidationException: The table does not have the specified index. DescribeTable still reported the table ACTIVE.On SQLite the command exits before any check with
Cannot connect to catalog: error with configuration: relative URL without a base, because it opens a PostgreSQL pool unconditionally (#177). It reports and drops nothing there, so no SQLite change is needed.Closes #652
Merge of #1003
23e9df454mergesmainata60c2b9f3(#1003).crates/app/src/cmd_catalog_check.rskeeps the comparison through the storage backend from this branch.crates/storage/src/diagnostics.rskeeps the key argument oftest_data_database_connectionfrom main and the two methods of this branch. The follow-ups:c23efefe6reads the connection string row throughdata_connection_stringwith the key that the command passes. It removes main'sdata_connection_text, which has no caller now.d22577ac6setswarm_throughputin the GSI input of the test deployment (feat: store and report WarmThroughput on tables and global secondary indexes #474).7208d60dfreads the KEK throughutil::status_key_source, asverifyandmigratedo. That helper sets up the locked key store first, so the DEK that the KEK unwraps is in locked memory. Withkey_fileset, on a host where memory locking fails andrequire_locked_memoryis true, the command now refuses, asverifyandmigratedo there.ceffc5e3eadds a test ofcheck_storage_relationson a catalog with a key ring.62787ee78changes the texts about DeleteTable. The merge brings 130 commits of main, and fix(postgres): keep a deleted table DELETING until its data tables drop #504 is one of them. On a separate data database, fix(postgres): keep a deleted table DELETING until its data tables drop #504 keeps the row of a table DELETING until its data tables drop. A DeleteTable therefore gives no orphan report now.At
62787ee78, against PostgreSQL 16 without pgvector and with a separate data database,--test catalog_checkgave 13 passed and--test key_ring_rowsgave 6 passed. With the plainSELECTof the earlier head put back intodata_pool, the new test failed with "relative URL without a base", and the 13catalog_checktests passed.Changes after the 19 November review
demohan's review of
62787ee78listed 11 fixes. At75c9a06c9, all of them are in:a9e49b89e: the diagnostics store's catalog pool connects with statement logging off. A catalog read that waits on a lock no longer prints aslow statementline in the report.2ae1b1983and9ee6fecca: the test deployment creates pgvector in its data database. WithEXTENDDB_EXPECT_VECTORS=1it fails when the server has no pgvector, so the storage test job always creates vec1.2d9801613: a test holds anindexeswrite past a 2 s budget. It checks the error of the check and of the drop, and that nothing was dropped. The short budget comes fromwith_index_lock_budget, which onlytest-hookscompiles.1c2ffe330: the text about index changes in progress now comes only from a 55P03 on theindexeslock attempt after the deadline. The command reports a statement timeout, a deadlock or a lock on another catalog table with the server's error.ee338c591: the listing resolves names as the server does. Asearch_pathset for the role on the data database no longer makes the check report a served table's relations missing.bcdeb4798: the key ring refusal is reported as not configured, so it prints on its own, as at the merge base.e516b0764andc4e2aaa32: the troubleshooting entry says that the report also stops after 30 s, and gives the wait of eachindexeswrite.425931239:crates/bin/tests/catalog_check.rsruns theextenddb catalog-checkbinary against the test deployment and checks its output and exit status. A new step of the storage test job runs it.753c44e4d: the tests fail instead of skipping whenEXTENDDB_TEST_PG_REQUIRED=1is set and the connection string is not.holdhelper for the test sessions that hold a lock. They also map the store factory's error once, set the job's test settings once, and format the tests.Each code change has a test that fails without it. At
ea1d0ec35, against PostgreSQL 16 with pgvector,EXTENDDB_TEST_PG_REQUIRED=1andEXTENDDB_EXPECT_VECTORS=1,--test catalog_checkgave 16 passed and--test key_ring_rows6 passed. The binary test passed there too. Againstpostgres:16without the switch, the two targets gave 16 and 6 passed. Both clippy commands ofclippy.ymlgave no warnings.4c1818682changes one test file. At that head,--test catalog_checkgave 16 passed on pgvector, and clippy of the crate's tests was clean.Conflicts with other open PRs
On 23 November,
git merge-treeof75c9a06c9with each open PR gave these conflicts, which the PRs do not have withmain. The resolution of each keeps both sides:crates/storage-postgres/src/lib.rs. Both branches addtest-hooksre-exports afterpub use credential_store::DbCredentialStore;: fix(storage-postgres): return UpdateTable before the GSI backfill finishes #708 forGSI_BUILD_SLOTSandhold_gsi_backfill_for_tests, this branch for the catalog-check pause.crates/storage-postgres/src/data/mod.rs. fix(storage): store U+0000 in strings on PostgreSQL and MongoDB #368 addsuse crate::catalog_json::{from_catalog_json, to_catalog_json};where this branch addsSTORAGE_RELATION_PREFIX.crates/storage-postgres/src/data/mod.rs, where both add a line at the start of the module list, and.github/workflows/integration.yml, inrun-postgres-storage-tests. There the resolution keeps the comment and thetimeout-minutes: 60of feat: add StartBulkPutItems and the bulk operation APIs #874 above theenv:block of this branch, and the new step of each branch.Testing done
The Gates and one row of the controls table name their own commit. The other runs in this section date from 2026-10-30, unless an item gives another date. They used PostgreSQL 16 with pgvector and a separate data database. They predate the merge of #1003 and #504, and none of them used a catalog with a key ring. The orphan report of two DeleteTable calls in the 2026-10-31 loop below came from the order before #504.
With a binary built from
4556ffcd4, on the deployment from the reproduction with the table recreated: the report is HEALTHY (exit 0). With a planted_ddb_00000000-0000-4000-8000-00000000deadand an unrelatedoperator_scratch, the report lists the planted relation only.--fixprintsDroppedfor it and nothing else. The four live relations andoperator_scratchremain. GetItem returns the item, and Query on gsi1 and lsi1 returns 3 and 1 items.The report and
--fixloops below ran on a binary built from90d429449, with a server running on the same deployment. They did not run again after the later production changes:c23efefe6,7208d60df,2d9801613,1c2ffe330,ee338c591(the listing moved fromcurrent_schema()topg_table_is_visible),bcdeb4798,a9e49b89e,2610afd55,ea1d0ec35,59b48d4b4and9754d3a1f, and the merges ofmaininc530d9f95,23e9df454and7309bc737. The command ran with a config for another port, so the PID refusal did not apply. In a loop, four traffic workers each created a table with a GSI, an LSI and a vector index, set its TTL and tagged it. Each then wrote three items, added a second GSI, queried both indexes and ran DeleteTable on the table. A fifth worker wrote items to one table.fe791ce87on a busier host: 3 of 300 runs exited 1. On that host 188 of 349 CreateTable calls took longer than 250 ms (p50 255 ms, max 808 ms). Each of the 3 runs was a case listed under "Reports that can be wrong while a server runs". Two runs reported missing relations for a table whose CreateTable took 558 ms in one run and 435 ms in the other. The third reported orphaned relations for two tables whose DeleteTable calls were between their catalog commit and their data commit. How many runs report a wrong result depends on how long CreateTable and DeleteTable take on the host. The server log has no deadlock and no error line.16c62f521) had 1 run of 300 exit 1, at 20:10:56Z. That binary requested the lock in attempts of 200 ms on each run. The run that exited 1 reported the four relations of a table whose CreateTable took 308 ms as missing. A waiting lock request can hold up a CreateTable's insert intoindexesfor one attempt, which counts against the 0.25 s delay. The check now requests the lock only when it finds an unnamed relation.--fixloop: 120 runs 0.3 s apart from 20:29:20Z to 20:31:20Z, each with a planted relation that no row names. Each run reported and dropped that relation and nothing else. No run kept or failed a drop, or reported a relation missing. The traffic made 253 CreateTable, 252 UpdateTable and 7,457 PutItem calls, all answered 200, and the server log has no deadlock and no error line.psqlsession in ACCESS SHARE mode for 6 s:--fixprintedFAILED to drop ...: another session held a lock on it for more than 1000 ms, so it was kept; run the command again: error returned from database: canceling statement due to lock timeoutand exited 1 after 1.33 s. After the session ended,--fixprintedDropped.data_database_connection_stringsetting absent, the report and--fixboth printedError: No data database connection string in settings. Run `extenddb init`.and exited 1.Tests
crates/storage-postgres/tests/catalog_check/(main.rs,report.rs,fix.rs,support.rs), run by the PostgreSQL storage-level step ofintegration.yml, which runs--tests. Each test initialises a deployment throughPostgresBootstrapperwith a separate data database. It creates a table with gsi1, lsi1 and vec1 (vec1 when pgvector is installed) and three items through the engine. Then it drivesPostgresCatalogStoreas theDiagnosticsStore. The deployment creates the extension in its data database. WithoutEXTENDDB_TEST_PG_CONNECTION_STRINGthe tests skip, and withEXTENDDB_TEST_PG_REQUIRED=1they fail instead. WithEXTENDDB_EXPECT_VECTORS=1, which the storage test job sets, a deployment without pgvector fails.The check:
index gsi1 of table 123456789012/ordersas its owner, and the renamed one orphaned.indexesleft open, a check that finds each relation named finishes in under 2 s.The drop:
--fixdrops a planted relation and keeps an unrelated table. It keeps the relations of a table created after the check when they are passed as stale candidates. It leaves the items and index rows intact.tablesorvector_indexes. Thetableswrite of the add finishes in under 900 ms, and anotherindexeswrite in under 1 s. The add commits while a lock attempt waits, and the relation is kept. The test runs at the default isolation and again with the store's sessions defaulting to REPEATABLE READ.FAILEDwith the lock message within 5 s, and a CreateTable sent meanwhile finishes within 5 s. Once the session ends, the drop succeeds.Already gone.crates/storage-postgres/tests/key_ring_rows.rswrites the connection string row under the DEK of a key ring. Thencheck_storage_relationsopens the row with the KEK. With the catalog key it returnsNotConfiguredwith the whole refusal for a catalog with a key ring.A unit test in
data/catalog_check.rschecks that a row in CREATING or DELETING, or one that is absent, does not count as settled.Negative controls
Each mutation was applied to a clean committed tree, and the
catalog_checktests were run. Then the file was restored and the tree checked clean before the next.indexesbefore the readtables,indexesandvector_indexes, as beforetables)indexeswriteSELECT set_config(...)and no READ COMMITTEDDROP TABLE IF EXISTSagain75c9a06c9: an index row counts as expected whatever its table's status (table_settled &&removed)falseif false &&An earlier control, run when the test file had its first four tests, built the expected names from account and table names instead of ids. All four tests failed.
Gates
At
75c9a06c9on 2026-11-23, against PostgreSQL 16 with pgvector, withEXTENDDB_TEST_PG_REQUIRED=1andEXTENDDB_EXPECT_VECTORS=1:cargo +1.97.0 fmt --all -- --check: clean.clippy.ymlon 1.97.0, with-p extenddb-storage -p extenddb-storage-postgres -p extenddb-app -p extenddb: no warnings.cargo +1.97.0 clippyof the same four crates with--all-targets -- -W clippy::pedantic: no warning on a line that this branch adds.cargo +1.91.1 check --locked -p extenddb-storage -p extenddb-storage-postgres -p extenddb-app -p extenddb --all-targets: clean.cargo +1.97.0 test --locked --libofextenddb-app,extenddb-storageandextenddb-storage-postgres: 105, 286 and 87 passed.cargo +1.97.0 test --locked -p extenddb-storage-postgres -p extenddb --test catalog_check --test key_ring_rows: the storagecatalog_checktarget 16 passed,key_ring_rows6 passed, and the binary test 1 passed.At
4c1818682, CI ran the workspace tests on Rust 1.91.1 and on stable, and the integration suites on all four backends. All of them passed.Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
ADR / RFC: n/a
Breaking changes
After the upgrade,
extenddb catalog-checkon PostgreSQL prints other lines: "Compared data relations with the catalog." in place of "Connected to data database.", the table or index that owns each missing relation, and an outcome for each relation that--fixhandles. With[auth.encryption] key_fileset, the command sets up the locked key store and reads the KEK before it reads the catalog. A KEK file that the file rule refuses then stops the command, as it stopsverifyandmigrate. So does a host where memory locking fails whilerequire_locked_memoryis true.extenddb verifyon PostgreSQL prints no slow-statement lines for its reads through the diagnostics store.DiagnosticsStoregains two methods with default bodies, so other backends compile unchanged. The change adds no command, flag or on-disk format.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.