Repository navigation
fix: answer TTL and tag calls during a table's DELETING window - #599
LeeroyHannigan wants to merge 20 commits into
Conversation
360f822 to
5b4c9ff
Compare
… service does DescribeTimeToLive on a DELETING table answers 400 ValidationException "Cannot describe time to live while table is in DELETING state: Current table state is DELETING", and on a CREATING table the same sentence naming CREATING; it is served on ACTIVE and UPDATING tables. UpdateTimeToLive on a DELETING table runs the same rules as on an ACTIVE one. Amazon DynamoDB answers these calls this way (measured 2026-10-25 and 2026-10-26). On ExtendDB the UpdateTimeToLive write goes to the catalog row, which the delete removes. ExtendDB answered UpdateTimeToLive on a DELETING table with 400 ResourceInUseException "Table <name> is not in ACTIVE state", because every backend's update_ttl admitted ACTIVE rows only, and DescribeTimeToLive with 200 on CREATING and DELETING tables, because nothing read the status. The engine reads the status with describe_table, since TableKeyInfo carries no status and MongoDB and Cassandra report a DELETING row as not found from the key-info read. The read is four catalog queries on PostgreSQL and SQLite and two on MongoDB and Cassandra, once per call. update_ttl admits DELETING beside ACTIVE in the conditional write on PostgreSQL, SQLite and MongoDB, and in the status check and both lightweight transactions on Cassandra. CREATING and UPDATING keep TableNotActive, and a missing table keeps TableNotFound. UpdateTimeToLive sends no index DDL for a table it read as DELETING, since the delete removes the data table or collection with its index. On PostgreSQL a disable's DROP INDEX waited with no lock timeout behind whatever held the data table and queued the table's data-plane requests behind it. On MongoDB an enable's create_index could create the collection again after the delete dropped it, and the collection outlived the table. MongoDB create_ttl_index also reads an ACTIVE catalog document only. A delete that commits between the status read and the write meets the index work, which the base refused at the write; on MongoDB the ACTIVE filter covers that order. TagResource and UntagResource on the ARN of a DELETING table answer 400 ResourceInUseException "Attempt to change a resource which is still in use: Table is being deleted: <name>", and ListTagsOfResource is served with the tags. On the table's stream ARN both writes and the read are served. Amazon DynamoDB answers this way (measured 2026-10-25 and 2026-10-26). ExtendDB answered ResourceNotFoundException for all three on MongoDB and Cassandra and accepted both writes on PostgreSQL and SQLite. An accepted TagResource on the table ARN writes an unconditioned tag row; on PostgreSQL the delete removes the ARN's tag rows before the catalog row, so a tag written between the two statements could outlive the table and be inherited by the next table of that name. The tag path reads the table's status before the key-info read, so all four backends reach the window's answers, and refuses the two writes when the ARN names the table. The key-info read still follows for every status but DELETING, so a tag call on an ACTIVE table sends seven catalog queries before its tag statements on PostgreSQL and SQLite, where it sent three, and four on MongoDB and Cassandra, where it sent two. The refusal removes the writes admitted during the window. A write whose status read came before the delete can still be written after the delete removed the tag rows, as before. ListTagsOfResource returns the tags for the whole window on PostgreSQL and SQLite. On MongoDB it returns no tags once the delete call has removed them; the service returns them for the whole window. A MongoDB storage test drives the tag and TTL handlers on a DELETING document, and devtools/run-mongodb-tests runs the crate's ignored deleting_window tests in CI. Closes #552 Closes #551
98bca8e to
ffb8f0e
Compare
…w-ttl-tags crates/engine/src/tagging.rs keeps the base branch's refuse_while_deleting as the one DELETING check of the tag path, with the deployment scope check from main. From this branch it keeps three things. The stream ARN exception: the service serves a tag write on the stream ARN during the window. The skip of the key-info read for a served request on a DELETING table. And arn_storage_error with its test. This branch's refuse_tag_write_while_deleting, arn_names_stream and the two unit tests of that check go: main's tag_subresource_is_stream and the base branch's check cover them. crates/storage-mongodb/Cargo.toml and crates/storage-postgres/Cargo.toml keep the base branch's dev-dependencies and this branch's dev-dependency on extenddb-engine, which the postgres crate already had from main. crates/storage-mongodb/src/deleting_window_tests.rs keeps the base branch's write conflict test and this branch's three TTL and handler tests after it. Those three now use the base branch's fixture, which skips without a replica set instead of carrying an ignore attribute. Their engine context names the backup runtime and the item authorizer main added. tests/python/test_deleting_window_control_plane.py keeps the base branch's index read test and with_index option and this branch's TTL and tag test classes and stream option.
…each window tag test The tag path's DELETING check now lives in tagging.rs alone, so table_lifecycle::being_deleted has no caller and goes. refuse_while_deleting reads the table's status through table_lifecycle::read_table_status, the read the TTL handlers make, instead of a describe_table call of its own. Main added the backup runtime and the item authorizer to OperationContext. The PostgreSQL TTL test's engine context now sets both. The MongoDB window tests skip without a replica set and run in the MongoDB workflow's replica set job. The run-mongodb-tests step for ignored window tests ran nothing and goes. The base branch tests the tag writes and the tag read on the table ARN during the window in TestDeletingWindowControlPlane. The copy of that test in TestDeletingWindowTags goes. Its wait for the service's tag update after the first tag write moves into the base branch's test.
…w-ttl-tags The base branch accepts a refused queued DeleteTable in the PostgreSQL snapshot test an_open_needs_one_connection_per_pool (bff95d9). No file conflicts.
devtools/check-crate-packages refuses a dev-dependency on a workspace crate that carries a version, because cargo then keeps it in the published manifest. The merge declared extenddb-engine in crates/storage-mongodb/Cargo.toml through the workspace key, which carries the version. It is now declared by path, as crates/storage-postgres/Cargo.toml declares it.
|
The branch is at fd12d6c, which merges #550's new head (9cbb9fe) into the fixes. Each inline thread has its own reply. The other items of the review: PR text. The body now follows the template. It gives the answers of #550's branch. The old text gave the answers from before #550, where PostgreSQL and SQLite accepted both writes. It gives the query counts per call, so "three before" applies to The "keeps its refusal" tests. The rows are one data table per backend (9a35e65), and their doc comments say that Coverage of the tag window. The cargo tests of the engine, SQLite and PostgreSQL still pass without the stream ARN rule. Without it, the MongoDB handler test and three wire rows fail. That run was at ec4c09c, whose production code and window tests are those of e4465ec. The MongoDB handler test also fails when a served request reads the key info. The DROP INDEX pin. The wire tests do not pin it.
Tests that set the status directly. On MongoDB The tag rows that a new table of the name lists. Filed as #1453 with your counts. The merge note for #598 missed a compile break. #598 deletes |
hitesh96db
left a comment
There was a problem hiding this comment.
Every item from my first review is fixed, or answered with a reason that held when re-measured. Two Minors remain. Checked at fd12d6ce on PostgreSQL and SQLite, with the MongoDB and wire tests read from CI. Every new test fails when its fix is removed.
Open:
- A disable can leave a stale index. If the status read after the
UpdateTimeToLivewrite fails, the disable answers 200 and leaves the TTL index on an ACTIVE table, and nothing drops it later. At the old head the same failure answered 500 before writing. Measured on PostgreSQL by renamingtable_restoresduring the disable: the indexidx_ttl__ddb_79acd9ff-429c-4fea-9307-bcc6c1201f87is present before and after, withdisable 200andTTL index work skipped ... relation "table_restores" does not existin the log. The code comment says the pending-index pass covers a failed read, and that holds for an enable only. Skip on a failed read only for an enable, or say in the comment that a disable leaves the index. - The
UpdateTimeToLivewindow difference is not documented. The body says DynamoDB answersUpdateTimeToLivewith 200 for the first 0.3 to 1.2 s afterDeleteTableand thenResourceInUseException. ExtendDB serves it for the whole window.grep -rn '0\.3 to 1\.2\|Table <name> is being deleted'overdocs/differences-from-dynamodb.md,crates/engine/src/ttl.rsand the wire test file finds nothing. The tag phase got that treatment in #1456, and this one needs the same.
Fixed or answered, with what I ran:
- The status is read after
update_ttl.a_mark_committed_during_the_ttl_write_sends_no_drop_indexpasses, and fails with the read moved back before the write. - A made-up stream label answers
ResourceNotFoundExceptionon PostgreSQL and SQLite (2 of 2) and stores no row. The MongoDB handler test and the wire row fail when the check is removed. a_failed_status_read_refuses_a_tag_writefails with the oldlet Ok(..) elseput back. A failed read goes througharn_storage_errorand answersRequested resource not found: ResourceArn: <arn> not found, which matches DynamoDB for a missing table ARN and a missing stream ARN (2 of 2).a_ttl_index_build_refuses_a_deleting_document_onlyfails with the ACTIVE filter put back and with no DELETING refusal.- With the DROP INDEX skip never applied, both PostgreSQL
ttl::handler tests fail. WithEXTENDDB_TEST_PG_REQUIREDset and no connection string, the PostgreSQL window tests panic. - Tag writes that change nothing are still refused on PostgreSQL and SQLite (2 of 2), and an enable in the window still answers
being updatedon PostgreSQL (2 of 2). Both are listed as remaining differences (#1457, #1454). - A residual window remains: a mark that commits after the post-write read and before the index statement still lets the DDL run. The comment says so, and it is a subset of #550's window.
- The wire test no longer calls
_settle_tags.DeleteTableis retried up to 30 times at 1 s ontags are being updated.
CI: 60 of 60 checks pass at fd12d6ce. The new PostgreSQL and MongoDB tests run, and the wire file reports 10 PASSED. The branch merges cleanly onto current main.
Not measured: the DELETING window on DynamoDB (I used the recorded measurements from the first round), Cassandra, and a live tag operation.
…w-ttl-tags The base branch's new head merges main at c057660 and adds its review fixes. Two files conflicted. crates/storage-sqlite/src/delete_table.rs: the base branch renamed its test module to tests and added main's two concurrent DeleteTable tests. This branch adds the UpdateTimeToLive test and the MetadataEngine and TimeToLiveStatus imports to that module. The merge keeps one module with all of these tests. docs/differences-from-dynamodb.md: the base branch rewrote the service cell of the DELETING window row and the first sentence of its ExtendDB cell. This branch appends the TTL and tag sentences to both cells. The merge keeps the base branch's row with this branch's sentences after it. No other file of this branch changed: its diff over the base branch is the same as before the merge.
UpdateTimeToLive reads the table's status after its write, so that it sends no index statement for a DELETING table. A failed read skipped the index statements too. For an enable, the TTL worker's pending-index pass builds the index later. A disable left the index on the ACTIVE table, and on SQLite and MongoDB no later pass drops it. Now a failed read skips an enable's index work only, and a disable's drop runs. The comment on the skip said that a PostgreSQL drop waits with no lock timeout. Since #1403, merged from main, the drop retries for up to 5 s behind a holder, and the comment now says so. The new PostgreSQL test renames table_restores for the call, so that describe_table fails and the TTL write does not. The disable answers 200 and drops the index.
The service serves UpdateTimeToLive for the first 0.3 to 1.2 s after DeleteTable returns. After that it answers ResourceInUseException with "Attempt to change a resource which is still in use: Table <name> is being deleted" (measured 2026-11-24). DescribeTable still reads DELETING then. The DELETING window row and the TTL row now say so. They also say that ExtendDB serves the call for as long as the row is DELETING (#1460). The rows already give the tag calls' phase (#1456).
…w-ttl-tags The base branch's head adds one commit since the last merge, a2cae34. It changes the served-traffic test in crates/storage-postgres/tests/deleting_window/data_plane.rs, which this branch does not change. No file conflicted.
The branch merges #550's new head twice (992cca4, 8831eaa). Two files conflicted in the first merge, the SQLite |
Changes since the last review
These commits answer hitesh96db's review of 25 Nov:
crates/storage-sqlite/src/delete_table.rsand theDELETINGwindow row ofdocs/differences-from-dynamodb.md. The merge keeps both sides.UpdateTimeToLivewrite skips an enable's index work only, and a disable's drop runs. The comment on the skip says that a PostgreSQL drop retries for up to 5 s (fix(storage-postgres): bound the lock wait of a TTL index drop #1403, merged from main).docs/differences-from-dynamodb.mdgives the service'sUpdateTimeToLivephase in the window.The message of ffb8f0e is no longer true at this head. Three parts are wrong: the CI step it names, the answers before this change, and the MongoDB tags. Whoever merges: please use the What section of this body as the squash message.
What
ExtendDB answers
DescribeTimeToLive,UpdateTimeToLive,TagResource,UntagResourceandListTagsOfResourceduring a table'sDELETINGwindow as Amazon DynamoDB answers them in the first seconds of the window. The change covers PostgreSQL, SQLite, MongoDB and Cassandra. "Differences from the service that remain" lists the answers that still differ.DescribeTimeToLiveon aDELETINGorCREATINGtable answersValidationExceptionCannot describe time to live while table is in <state> state: Current table state is <state>. One message key,DescribeTtlInState, builds both sentences.update_ttladmitsDELETINGbesideACTIVEon every backend. The handler reads the table's status after the write. It sends no index statement for aDELETINGtable, becauseDeleteTabledrops the data table or collection with its index. A row that is gone skips the index statements too. After a failed read an enable skips its index work, with a warning, and the TTL worker's pending-index pass builds the index later. A disable's drop runs. A mark that commits after that read and before the index statements still lets them run.create_ttl_indexanswersTableNotActivefor aDELETINGdocument beforecreate_index, which would create the dropped collection again. Other statuses build the index as before.table_lifecycle::read_table_description). On aDELETINGtable,TagResourceandUntagResourceon the table ARN keep fix: answer requests during a table's DELETING window as the service does #550'sResourceInUseException, andListTagsOfResourceis served. All three are served on the table's latest stream ARN. Any other stream label answersResourceNotFoundException.DELETINGtable skips the key-info read, which reads such a row as not found on MongoDB and Cassandra.docs/differences-from-dynamodb.mddescribes the five calls in the window and the differences that remain.On PostgreSQL the widened UPDATE of
update_ttlnow matches aDELETINGrow, so it waits for that row's lock when another transaction holds it. The control-plane pass holdsFOR UPDATE SKIP LOCKEDon each dueDELETINGrow until it commits its drops, and the statement has no lock timeout. In the reviewer's run the UPDATE waited 3.0 s behind a heldFOR UPDATE, where #550's branch answeredTableNotActiveafter 1.6 ms.On Cassandra
DeleteTabledoes not mark the rowDELETINGwithout #598. The onlyDELETINGrow there is a restore target that ExtendDB is deleting, and the new answers apply to it.Why
Fixes #551
Fixes #552
While a table is
DELETING, Amazon DynamoDB answers these calls as follows, on the table and on the Amazon Resource Name (ARN) of its stream. Measured on 2026-10-25, 2026-10-26 and 2026-11-20:A stream ARN whose label names no stream gets that ResourceNotFoundException with its own ARN. This was measured on 2026-11-20 on a DELETING table and on 2026-11-24 on a table that does not exist. DescribeTimeToLive on a CREATING table answers the same ValidationException with CREATING in the sentence, and is served on an UPDATING table (measured 2026-10-26).
On #550's branch, the base of this PR (154f0da, and a2cae34 at this head), the answers were different:
Catalog cost
The status read is
describe_table: four catalog queries on PostgreSQL and SQLite, and two on MongoDB and Cassandra. The key-info read after it is three queries and two. These are the counts before the TTL or tag statements of a call on a table that is notDELETING:On a
DELETINGtable a served tag request sends the status read only. UpdateTimeToLive skips its TTL read after the write and the index statements. These are control-plane calls, and the item and batch paths are unchanged.Differences from the service that remain
DeleteTabledeleted the table's tag rows. The next table created with that name then lists the tag. This is main's behaviour too (A TagResource that races DeleteTable can leave a tag row that the next table of the name lists #1453).Overlaps with other PRs and merge notes
refuse_while_deleting, and the one builder of its refusal,create_table::table_being_deleted. This branch extends that function and keeps no second copy. The PR targets main once fix: answer requests during a table's DELETING window as the service does #550 merges.tests/python/test_deleting_window_control_plane.py: keep this branch'sTestDeletingWindowTimeToLiveAndStreamTags, thenTestConcurrentDeleteTable.docs/differences-from-dynamodb.md: keep this branch's row, with fix(cassandra): fence concurrent DeleteTable with a lease #598's Cassandra sentences in place of the old one.crates/storage-cassandra/tests/direct/deleting_window.rsmerges with no conflict but does not compile, because fix(cassandra): fence concurrent DeleteTable with a lease #598 deletesstatus_of. The second of the two to merge changesstatus_of(&engine, &account.account_id)inupdate_ttl_during_the_window_is_servedtorow_status(&engine, &account.account_id, TABLE). A local merge of the two fix heads with these resolutions builds the Cassandra test binary, and its three delete modules pass (14 tests). Without the change the build fails with E0425 onstatus_of.crates/engine/src/tagging.rs, where it splitsvalidate_resource_arn. The second to merge keeps the service's order: the tag checks come before the DELETING refusal.handle_update_time_to_liveon a PostgreSQL DROP INDEX, which said the drop would wait with no lock timeout.Testing done
At 8831eaa, with toolchain 1.97.0 and postgres:16, mongo:7 (replica set) and cassandra:4.1 containers on 127.0.0.1:
cargo +1.97.0 fmt --all -- --checkand the two clippy commands of.github/workflows/clippy.ymlwith-D warnings, on the whole workspace: clean.cargo +1.94.0 check --all-targetsonextenddb-core,extenddb-engine,extenddb-server,extenddb-storageand the four backend crates: clean.extenddb-core1260 passed and 1 ignored,extenddb-engine985,extenddb-server523,extenddb-storage295,extenddb-storage-sqlite344 and 1 ignored,extenddb-storage-postgres93,extenddb-storage-mongodb209 and 86 ignored,extenddb-storage-cassandra192. The MongoDB run used the replica set, so itsdeleting_window_tests(12) ran there. Seven backup tests fail on this host (storage-sqlite: the two write_lock_tests fail when an ancestor of the Cargo target directory is owned by another user #1414): five inbackup_store::testsofextenddb-serverand two inbackup_catalog::write_lock_testsofextenddb-storage-sqlite. Another user owns an ancestor directory of the paths they use. This PR does not change them.cargo test -p extenddb-wasm-adapter: 4 passed, with theparitycorpus test. The clippy step of.github/workflows/wasm.ymlforwasm32-unknown-unknown: clean. This host has no clang, so the run used a stand-in C compiler and archiver. Clippy does not link.extenddb-storage-postgres --test doc_version_literals: 3 passed.cargo test --no-fail-fast -p extenddb-storage-postgres --testson postgres:16 withEXTENDDB_TEST_PG_REQUIRED=1: 514 passed and 2 ignored,deleting_window(15) among them. Five tests fail at the refusal ofcheck_private_ancestors, because another user owns an ancestor directory of the backup root on this host. They arestore_identity::a_root_owned_by_another_catalog_is_unhealthy,store_identity::host_local_roots_under_one_label_leave_the_second_instance_unhealthyandstore_identity::two_instances_on_one_empty_root_end_with_one_idinbackup_restore, anda_store_backed_backup_and_restore_keep_key_names_that_hold_u0000_and_u0001anditems_restored_by_the_restore_job_reach_a_gsi_keyed_on_a_u0001_nameincatalog_nul_backup_jobs.extenddb-storage-mongodb --lib -- --ignored live_deleteon the replica set: 2 passed.extenddb-storage-cassandra --features test-hooks --test direct_integration deleting_windowon cassandra:4.1 with PasswordAuthenticator andEXTENDDB_TEST_CASSANDRA=required: 4 passed.tests/python/test_deleting_window_control_plane.pyandtests/test_table_operations.py::TestDeleteTable, against servers built from this head on 127.0.0.1: 17 passed on PostgreSQL. On SQLite the 7TestDeleteTabletests passed, and the 10 tests of the window file skipped, because the file holds the window through PostgreSQL only.python3 -m pytest --collect-only -qoftests/(7314 tests) and oftests/python(830): no error.Controls, each with the tests kept:
ttl::a_failed_status_read_after_a_disable_still_drops_the_index(PostgreSQL) fails with the old skip of any failed read: the index stays.tags::a_failed_status_read_refuses_a_tag_writeandttl::a_mark_committed_during_the_ttl_write_sends_no_drop_indexon PostgreSQL,ttl::a_ttl_index_build_refuses_a_deleting_document_onlyandttl::engine_tag_and_ttl_handlers_during_the_windowon MongoDB, and the wire rowmade-up-stream-label(run at ec4c09c, whose production code and window tests are those of e4465ec).ttl::fail. Without the stream ARN rule, the MongoDB handler test and three wire rows fail. When a served request reads the key info, the MongoDB handler test fails (run at ec4c09c).CI runs the new tests in
integration.yml(cargo test --release -p extenddb-storage-postgres --tests, anddevtools/run-tests --extenddb --pytest --comprehensivefor the wire file), inintegration-mongodb.yml(--lib deleting_window_tests) and inintegration-cassandra.yml(--test direct_integration).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
Compared with #550's branch, a client sees these answers change:
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.