Repository navigation
fix: answer requests during a table's DELETING window as the service does - #550
LeeroyHannigan wants to merge 43 commits into
Conversation
7075440 to
b0ca085
Compare
b0ca085 to
360f822
Compare
…does A second DeleteTable and an UpdateTable during a table's DELETING window answer 400 ResourceInUseException with "Attempt to change a resource which is still in use: Table is being deleted: <name>" on all four backends. PutItem, GetItem, Query and Scan are served during the window on PostgreSQL and SQLite and answer ResourceNotFoundException once the table is gone; a write made in the window goes away with the table. Two concurrent DeleteTable calls on one ACTIVE table get one description and one ResourceInUseException on PostgreSQL, SQLite and MongoDB. All measured against the service on 2026-10-24 and 2026-10-25. DeleteTable on PostgreSQL and SQLite looked the name up with a status filter that excluded DELETING rows and answered ResourceNotFoundException. On MongoDB and Cassandra it had no status filter and ran the delete again. UpdateTable on every backend answered "Table <name> is not in ACTIVE state", the sentence for the other non-ACTIVE statuses. The data plane on PostgreSQL and SQLite answered ResourceNotFoundException for the whole window, because the key-info read that authorization and the handlers share mapped a DELETING row to not found. On SQLite the DeleteTable status lookup ran outside the write transaction and on MongoDB the DELETING mark was unconditioned, so two concurrent calls both proceeded. New StorageError::TableBeingDeleted, worded once in the engine's message table and mapped to ResourceInUseException by the DeleteTable, UpdateTable and TTL error mappers. The key-info read on PostgreSQL and SQLite reads a DELETING row as found; a statement or transaction that reaches a data table the control plane has dropped is answered as not found instead of as an internal error. SQLite's DeleteTable looks the row up inside its write transaction and fences the DELETING mark on the table id; MongoDB's mark is an update_one conditioned on the table id and status, and its final delete_one is keyed on both. On PostgreSQL and SQLite the DELETING row exists only on the asynchronous DeleteTable path (control_plane_delay_seconds of 1 or more; the default is 0.25), so on a default deployment the new answers are reachable after #504, which marks the row on both paths. On Cassandra DeleteTable never marks the row, so the check is reachable only for an abandoned restore target, and the data plane there is unchanged. MongoDB drops the collections inside the DeleteTable call a few milliseconds after the mark, so its data plane keeps answering not found during that window. The differences document carries the per-backend shape. Tests: engine unit tests for the three mappers; storage-level tests on each backend for both control-plane requests and for a CREATING table keeping its answer; on PostgreSQL and SQLite, for the four data-plane requests during the window, for a put, a get and the two transaction calls after the data table is dropped under a DELETING row, and for ten rounds of two concurrent DeleteTable calls (also on MongoDB); a dual-target wire test for the PostgreSQL case that holds the data table locked from a second connection, with the data-plane rows, which skips on a server whose delay is under 1 s until #504 lands. The PostgreSQL storage-level CI step runs the new binary. The tests #395 added for that call now expect the service's refusal (12 of 12 runs on 2026-10-30). Closes #505
…ne sweep The three deleting_window tests set a fresh table's catalog row to DELETING to produce the window. A fresh table carries its activation deadline in status_transition_at, and process_control_plane_transitions removes any DELETING row whose deadline has passed: it clears the table's TTL entries in the account keyspace, drops the indexes and the data table, and deletes the row. The tests left their rows in place, so the next test in the binary to run the sweep after their account keyspaces were dropped failed on the missing keyspace. On CI that was index::test_ttl_on_a_table_with_an_async_gsi_is_refused_as_a_validation_error in the cassandra-storage job. The sequence reproduces locally with --test-threads=1 on deleting_window, groups, then that test. set_status now clears status_transition_at together with the status, the column activation clears, so the sweep's deadline filter excludes the row for the rest of the test. Each test deletes its row before it returns. The same sequence passes with the change, the full direct_integration binary passes in parallel (152 of 152), and the catalog holds no DeletingWindowTable row afterwards.
360f822 to
5b4c9ff
Compare
|
@robinnsc, rebasing this onto #395 meant picking one answer for a DeleteTable of a table that's already DELETING. I kept the refusal, since the service gave it in 12 of 12 runs this morning, and changed your three tests of that call to expect it. The details are in the description under "Rebase on #395". |
robinnsc
left a comment
There was a problem hiding this comment.
Most of this works as described. With the window held (a reader on the data table on PostgreSQL, a long delay on SQLite), the second DeleteTable and every UpdateTable kind get the measured ResourceInUseException sentence, and the data plane, batch and transact calls are served on both backends. After the drop nothing answers 500 and no data table is recreated, and N concurrent DeleteTable calls had exactly one winner on all three backends. Writes made in the window never showed up in a new table of the same name, and a crash mid-delete is recovered on PostgreSQL and SQLite. Head and main came out the same for PutItem/GetItem/Query latency on PostgreSQL and SQLite. The new PostgreSQL wire tests fail on main and pass here.
The one I'd hold this for is the MongoDB stuck-DELETING case in the first inline comment. The rest are smaller.
Other notes:
- TagResource and UntagResource now answer 200 during the window on PostgreSQL and SQLite, where main refused them and, per the description, the service refuses them too. It might be worth keeping those two refused on a DELETING row rather than letting the key-info change widen them.
- On PostgreSQL, the abandoned-restore cleanup (
abort_restore,backup_engine.rs:702) also marks rows DELETING, so a partly copied restore target is now served for that window. The description gives that same reason for Cassandra answering not found. It's a small window, but it might be worth telling the two cases apart infetch_table_key_info. - None of the MongoDB
deleting_window_testsrun in CI: they're#[ignore]and the MongoDB workflow only runssnapshot_engine. deleting_window_data_tests.rs:236needs<crate>/../../targetor an absoluteCARGO_TARGET_DIR;snapshot_engine.rs:489already derives the path fromcurrent_exe().- On SQLite the lookup now runs inside
BEGIN IMMEDIATE, so therows_affected() == 0arm after the fenced mark can't be reached. - Description: the "Change" bullet about looking the name up without the status filter describes the pre-rebase mechanism; the "Rebase on #395" section and the code say otherwise.
| // below. A second DeleteTable in that window is refused the way the | ||
| // service refuses it (measured 2026-10-24), before the deletion | ||
| // protection check, as the SQL backends order it. | ||
| if desc.table_status == TableStatus::Deleting { |
There was a problem hiding this comment.
I think this needs a way to finish a delete that stopped partway. On MongoDB the mark, the drops, the tag and stream cleanup and the final delete_one all run inside the request, and nothing else removes a DELETING document. On main, the next DeleteTable re-ran those idempotent steps and finished. With this refusal, anything that stops between the mark and the delete_one leaves the table DELETING for good. That includes a client timeout, a crash, or an error from one of the drops. CreateTable of the name then answers Table already exists.
Repro: a GSI + stream table, with a transaction holding the data collection for 10 s so the drop waits, and DeleteTable with read_timeout=2. botocore's own retry of the timed-out call got Table is being deleted, and the table was still DELETING after 60 s and after a server restart. kill -9 mid-drop gave the same result. On main the retry answered 200 and the name was reusable 3 s later.
Could consider letting a DeleteTable that finds DELETING run the remaining steps and still answer ResourceInUseException, or giving the Mongo control-plane worker a pass over DELETING documents.
There was a problem hiding this comment.
Fixed in e583912. The steps after the DELETING mark now run in a task of their own that the request awaits, so a client that gives up on the call no longer cancels them. The mark also records a time 60 s ahead, and the control-plane worker finishes any delete whose document is still DELETING past that time, which covers a step that failed and a process that died. A second DeleteTable during the window still answers ResourceInUseException.
I ran your repro against a build of the old head and against this one: a GSI and stream table, a transaction holding the data collection for 10 s, and DeleteTable with read_timeout=2. On the old head botocore's retry got Table is being deleted, the table was still DELETING 75 s later, and CreateTable of the name answered Table already exists. With kill -9 mid-drop and a restart it was still DELETING 100 s later. On this build the timed-out delete finished on its own once the transaction ended, 11 s after the call. In the kill case the control plane removed the table 61 s after the mark. CreateTable of the name answered 200 both times.
a_delete_table_whose_caller_gives_up_still_finishes and the_control_plane_finishes_a_delete_left_deleting fail with the task and the worker pass taken out. The MongoDB DELETING window tests are no longer #[ignore]d and run in the MongoDB workflow's replica set job.
The request's task and the control plane can run the steps at once, and a table created into the name has the same ARN, so 34a9c9a removes the tags in one transaction with the document, and only when that run removed it. a_late_second_run_of_a_delete_leaves_a_new_table_of_the_name_whole fails without it, with the new table's tag gone.
| // plane drops them, so the data plane reads a DELETING row as found; | ||
| // a statement that reaches a dropped data table is answered as not | ||
| // found by the `DataEngine` implementation. | ||
| "ACTIVE" | "DELETING" => {} |
There was a problem hiding this comment.
With DELETING read as found here (and at storage-sqlite/src/data/ddl.rs:367), one data-plane read during the window puts the DELETING key info in the key-info cache. Nothing invalidates it when the control plane removes the table. Base-table calls then fall through to the dropped-table mapping and answer ResourceNotFoundException. A Query or Scan with IndexName, though, answers ValidationException: The table does not have the specified index for about 30 s until the soft TTL refreshes. PostgreSQL showed this at delay 1 and at the default 0.25 with a reader holding the table, and SQLite showed it at delay 1. On main a DELETING row is never cached, so it was ResourceNotFoundException from t=0. Maybe don't cache a DELETING answer, or re-check the catalog on IndexNotFound with a cached entry.
There was a problem hiding this comment.
Fixed in f2a777a, with your second suggestion. When an index name does not resolve, Query and Scan now ask the catalog for the table again, uncached. A table it no longer has is answered ResourceNotFoundException and its cache entry is dropped; a table it still has keeps the ValidationException. The extra read runs only on that error path.
I kept the DELETING answer cacheable. The key info carries no status, so not caching it would need a status field on TableKeyInfo or a describe on every load.
test_index_reads_after_the_table_is_gone_are_not_found (PostgreSQL, lock held, delay 0.05) does a GetItem in the window, waits for the table to go, then runs Query and Scan on the index. Both answer ResourceNotFoundException on this branch. With the engine change reverted the test fails at the Query, which answers ValidationException.
| delay_secs = float(delay) if delay is not None else 0.25 | ||
| except ValueError: | ||
| delay_secs = 0.25 | ||
| if delay_secs < 1.0: |
There was a problem hiding this comment.
On PostgreSQL the window already opens at the default delay. Since #395, a DeleteTable that finds an ACCESS SHARE holder takes the async branch with schedule_secs = 0.0 and leaves the row DELETING. At 0.25 with the lock held, DeleteTable answered 200 DELETING on both main and head. With this check disabled, the three tests passed on head and failed on main at 0.25, so they'd run and discriminate in CI, which pins 0.05. Could consider dropping the delay condition for PostgreSQL. The docstring and the description's "exists only on the asynchronous path / once #504 lands" would need the same correction.
There was a problem hiding this comment.
Fixed in 657e1c0. The tests no longer read the delay, and the docstring now says that a DeleteTable that finds another session holding the data table marks the row DELETING and leaves the drop to the control plane at any delay. At 0.05, the CI job's value, all five tests in the file ran and passed on this branch, none skipped. The description no longer says the window exists only on the asynchronous path.
| /// unapplied migration shows as `ResourceNotFoundException` on the wire and as | ||
| /// the named table in the server log. | ||
| fn dropped_table_as_not_found(key_info: &TableKeyInfo, e: StorageError) -> StorageError { | ||
| if super::index::is_no_such_table(&e) { |
There was a problem hiding this comment.
This matches any no such table, not just the table's own _ddb_<id> and index tables. With stream_records renamed away on a stream-enabled ACTIVE table, PutItem answered 400 ResourceNotFoundException with no log line. Main answered 500 and logged no such table: stream_records at ERROR. So an unapplied migration would show up as "not found" on a table DescribeTable reports ACTIVE. Matching by name, the way PostgreSQL's data_table_missing does, would keep the intended case and leave the rest as Internal. On PostgreSQL a missing GSI table is also IndexNotFound, while here it comes out as TableNotFound.
There was a problem hiding this comment.
Fixed in acb03bf. The funnel now matches only no such table: _ddb_ (with or without main.), the names of this backend's data and index tables, the way PostgreSQL's data_table_missing matches its own. A missing stream_shards, stream_records, gsi_pending or vector_index_holds stays an internal error and is logged. a_missing_shared_table_stays_internal fails with the old matcher.
I left a missing index table on an index read as TableNotFound on SQLite. In the DELETING window that error means the whole table is being dropped, and ResourceNotFoundException is the service's answer once the table is gone. The case where IndexNotFound is right on its own is a GSI dropped by UpdateTable under a running read. If you would rather have the two backends match, I can move SQLite to PostgreSQL's mapping here.
There was a problem hiding this comment.
On the second half: SQLite keeps its answer, and PostgreSQL's stays as it is.
An index read can find the index in the catalog and then reach the index table after the control plane drops it. SQLite answers that read ResourceNotFoundException through the dropped-table funnel. PostgreSQL answers ValidationException The table does not have the specified index, because #401's read_target_gone maps a missing index table to IndexNotFound.
The service's answer is SQLite's. On 24 Nov, Query and Scan with IndexName on tables that do not exist answered 400 ResourceNotFoundException Requested resource not found. This PR does not change #401's mapping. Once the catalog row is gone, both backends answer ResourceNotFoundException. The description states this under "Measured, not changed here".
| ) | ||
|
|
||
| def test_delete_of_a_deleting_table_returns_its_description( | ||
| def test_delete_of_a_deleting_table_is_refused_as_being_deleted( |
There was a problem hiding this comment.
create_and_cleanup_table in conftest.py treats any ResourceInUseException at teardown as UPDATING and calls wait_for_active. With delay 1 on PostgreSQL, test_delete_existing_table now errors at teardown: ResourceInUse "Table is being deleted", then ResourceNotFound from DescribeTable. Main passes that test. It only shows at delay ≥ 1 today, but once #504 lands it will hit the default path. Might be worth having the fixture go straight to wait_for_deleted on that sentence.
There was a problem hiding this comment.
Fixed in 3a0ee7d. On Table is being deleted the fixture now goes straight to wait_for_deleted. With delay 1 on PostgreSQL, test_delete_existing_table passes with the change and errors at teardown without it, with ResourceNotFoundException from DescribeTable, as you saw.
|
|
||
| /// Two concurrent DeleteTable calls on one ACTIVE table: the first locks the | ||
| /// row `FOR UPDATE` and marks it DELETING; the second, blocked on that lock, | ||
| /// re-reads the row after the commit, finds it excluded by the status filter, |
There was a problem hiding this comment.
nit: the select now fetches DELETING rows and answers them directly (delete_table.rs:70), so the "excluded by the status filter ... from the unfiltered lookup" wording is left over from before the rebase.
There was a problem hiding this comment.
Fixed in 1de1816. The comment now says the second call reads the row again after the first commits, finds it DELETING and answers TableBeingDeleted.
A second DeleteTable during the DELETING window is refused, as the service refuses it, so on MongoDB nothing re-ran the steps of a delete that stopped between the mark and the removal of the table document. A client read timeout dropped the request future and the steps with it, and a crash or a failed drop did the same. The document then stayed DELETING and CreateTable of the name answered "Table already exists". The steps after the mark now run in a task of their own that the request awaits. Dropping the request detaches the task instead of cancelling it, so a delete stalled behind a transaction finishes once the transaction ends. The mark also writes a status_transition_at 60 s ahead, and the control-plane worker finishes every DELETING document whose time has passed, or that has none (a document an earlier build left). The worker claims a document by moving its time forward, conditioned on the value it read, so one process runs the steps at a time and a step that keeps failing is retried once a minute. The steps are idempotent: drop the data and index collections, remove the tags and the stream state, then delete only this table id's DELETING document. The DELETING window tests no longer carry #[ignore]: they skip without EXTENDDB_TEST_MONGODB_URI unless EXTENDDB_TEST_MONGODB_REQUIRED is set, and the MongoDB workflow runs them against its replica set.
…runs The second DeleteTable reads the row again after the first commits, finds it DELETING and answers TableBeingDeleted. Since the rebase on #395 there is no status filter on that select and no second lookup.
… removed The restore sweep claims an abandoned restore target by marking its row DELETING, then drops its data tables. Once the data plane read a DELETING row as found, a partly copied target was served for as long as the drop waited. The claim now sets the row's transition time to the epoch, a time no DeleteTable mark carries: DeleteTable schedules the removal at or after the time it runs. The key-info and index lookups read a DELETING row with that transition time as CREATING, so the target stays ResourceNotFoundException, as a table the service is still restoring is. The control plane still finds the row due, so a drop that fails is finished later as before.
LJMart11
left a comment
There was a problem hiding this comment.
Reviewed at 9cbb9fe. Ran the PostgreSQL deleting_window and table_snapshot targets against a private PostgreSQL 16, plus the engine and SQLite lib tests, all green. The review covers how the head reads restore-target rows that an earlier release claimed for removal.
1 finding is left inline.
| /// `CREATING` restore target it was, which the data plane answers as not | ||
| /// found, as the service answers a table it is still restoring; a row | ||
| /// `DeleteTable` marked is served until it is gone. | ||
| const DATA_PLANE_STATUS: &str = "CASE WHEN table_status = 'DELETING' \ |
There was a problem hiding this comment.
This classifier treats a restore-target claim as not found only when its transition time is the epoch, but v1.0.0's abort_restore writes NOW(), and that row can outlive an upgrade (a failed drop) or come from a v1.0.0 server sharing the catalog. On this head, a target marked as v1.0.0 marks it returned Ok from table_key_info and PutItem wrote 1 row into the half-restored table; with 'epoch' it answered TableNotFound. Keying the check on the table_restores row, or migrating existing claims to the epoch, plus a test that seeds a NOW() claim, would close this.
There was a problem hiding this comment.
Fixed in a1e2494. DATA_PLANE_STATUS in crates/storage-postgres/src/data/ddl.rs now reads a DELETING row as the CREATING restore target it was when the row's table_restores record is not DONE. A restore sets DONE only in the transaction that makes its target ACTIVE, and abort_restore claims only a CREATING target. So a claimed target's record is RUNNING or FAILED, whatever release wrote the claim, and abort_restore writes NOW() again.
a_restore_target_claimed_by_an_earlier_release_is_not_found in crates/storage-postgres/tests/deleting_window.rs seeds DELETING rows with NOW() and a RUNNING, a FAILED and a DONE record. The first two answer TableNotFound from table_key_info and index_info. The DONE row, a restored table that DeleteTable marked, is served. With the epoch check put back, the test fails on the RUNNING row.
demohan
left a comment
There was a problem hiding this comment.
The control plane answers the DELETING window as the service does at 9cbb9fe, and the window itself now behaves in ways main did not. A second DeleteTable, UpdateTable with OnDemandThroughput or a GSI Delete, TagResource and UntagResource during the window return the service's Attempt to change a resource which is still in use: Table is being deleted: <T>, on SQLite and PostgreSQL in every run and on the service in us-east-1 for 5 of 5 tables, where main answered 200, Table <T> is not in ACTIVE state and 404. The data plane is served through the window with no 500, the #505 case is served where main answered 404, index reads after the table is gone answer ResourceNotFoundException with no stale cache entry, and on MongoDB the table is gone 0.1 s after the answer. 17 negative controls fail as they should, every new test fails on main's binary, and fmt, both clippy commands and the 1.91.1 check are clean; CI is green on 65 of 65.
On the service the window has two phases: single-item reads and writes, Query and Scan are served for the first 2.7 to 5.7 s of a 6.4 to 8.1 s window, batch, transaction and PartiQL calls for the first 0.5 to 2.1 s, ListTagsOfResource for 0.6 to 1.4 s and the tag sentence for 0.6 to 1.5 s, and after that all of them answer ResourceNotFoundException while DescribeTable still reads DELETING. This head serves the whole window, which is a reasonable choice, but docs/differences-from-dynamodb.md:60, the ddl.rs comment near line 562, key_info_cache.rs:163-166 and the body say the service serves it until the table is gone.
The branch conflicts with main at 222d80a in five files, and after they are resolved sqlx 0.9.1 (#1166) refuses 31 dynamic queries, two of them this branch's own at ddl.rs:387 and :548.
I will approve once an index read in the PostgreSQL gap answers ResourceNotFoundException, served traffic cannot hold the drop off, a second server's cache does not refuse a re-created table, and the dropped-table handling has tests on the four requests below.
crates/storage-postgres/src/data/data_engine.rs:469
With the data tables dropped and the catalog row still DELETING, held open for 23 s, Query and Scan with IndexName on gsi1, lsi1 and gsi2 answer ValidationException The table does not have the specified index: gsi1, 75 times each; main answered ResourceNotFoundException on all 110 calls, as the service does for index reads late in its window. On main a DELETING row was refused before the index table was read. Answering TableNotFound when the index table is missing and the row is DELETING, or the base table is gone, would match. In the same gap ExecuteTransaction answers plain ResourceNotFoundException where main answers TransactionCanceledException with ResourceNotFound; the service gave both in different runs.
crates/storage/src/key_info_cache.rs:163
With two servers on one PostgreSQL catalog, server B reads the table once during the window, server A removes it and creates the name again, and B answers PutItem with ResourceNotFoundException for 24.7 s on the ACTIVE table, 2 of 2 runs; main answered 200 at once. Main shows the same 24.7 s only when B read the table before the DeleteTable, so caching the DELETING row as found widens it.
crates/storage-sqlite/src/data/data_engine.rs:1
No test holds the dropped-table handling of SQLite Query and Scan: with it removed, all 337 lib tests pass. The same holds for PostgreSQL UpdateItem and DeleteItem, where reverting all 14 db_error mappings in update_item.rs and delete_item.rs still passes deleting_window 7 of 7; only PutItem, GetItem, TransactGetItems and TransactWriteItems are tested after a drop. The status check at ddl.rs:548 and the table_id key on MongoDB's final delete_one in remove_deleting_document pass with their guards removed too.
| @@ -372,12 +382,12 @@ impl PostgresEngine { | |||
| account_id: &str, | |||
There was a problem hiding this comment.
drop_unless_held with LockHolders::Any now waits on the client traffic this branch serves through the window, so the drop can be held off and every write accepted meanwhile is thrown away. With a reader lock released about 2 s after DeleteTable and six client threads running, the catalog row was gone at 2.4 and 3.2 s on main and at 36.2, 5.7, 7.3 and 3.2 s on this head, and once not gone after 28 s; with an 8 s hold every request answered 200 for the whole 14 s run. SQLite is not affected.
There was a problem hiding this comment.
Fixed in a1e2494, with the test in a2cae34. drop_unless_held in crates/storage-postgres/src/worker_store.rs now reads the holders' transaction ids twice, 50 ms apart. It skips the drop only when one transaction holds a lock at both reads. A request's transaction ends inside that time, so the drop is tried. The drop waits for the requests in flight, and the requests after it queue behind its lock and then find the table gone. A snapshot, the backup, an index build or VACUUM is still seen at both reads, and held_deleting_tables_are_probed_not_waited_on passes unchanged.
served_requests_do_not_hold_off_the_drop in crates/storage-postgres/tests/deleting_window/data_plane.rs holds the window open with a reader. It starts a request every 10 ms that holds the data table for 40 ms, releases the reader, and runs control-plane passes. The row was gone 0.19 to 0.26 s after the release, in 3 of 3 runs. With the old single probe, the row was still DELETING after 5 s, in 2 of 2 runs.
| @@ -0,0 +1,245 @@ | |||
| # Copyright 2026 ExtendDB contributors | |||
There was a problem hiding this comment.
Optional. The "window write is gone" check is a GetItem on a name that no longer exists, which always fails, so it cannot show whether the write survived. The file is skipped on SQLite and Cassandra and not run on MongoDB; SQLite could hold the window with a delay of 1 s or more.
There was a problem hiding this comment.
The check now creates a table under the name again and reads the key the window wrote. The new table does not have it (bd6b452).
The file stays PostgreSQL-only. On SQLite the window needs a control_plane_delay_seconds of 1 or more, and the other tests on a shared server do not expect that delay. The SQLite rows stay in crates/storage-sqlite/src/deleting_window_data_tests.rs, which 1159934 extends to Query and Scan.
Add ErrorMessageKey::TableBeingDeleted (the name #550 uses) and build the refusal of a second DeleteTable from it on PostgreSQL and SQLite. Signed-off-by: Hitesh Sharma <hts@amazon.com>
Main is at c057660, 43 commits after the last merge. Thirteen files conflicted. Main's #1411 and #1446 change the same DeleteTable paths as this branch, so the merge keeps one copy of each check. #1411 refuses a second DeleteTable of a DELETING table on PostgreSQL and SQLite with StorageError::IndexesInUse and the TableBeingDeleted message. This branch refuses it with StorageError::TableBeingDeleted, which UpdateTable, MongoDB and Cassandra also raise. The merge keeps that variant, removes the second check that git placed after it in crates/storage-postgres/src/delete_table.rs, and removes deleting_refusal from crates/storage-sqlite/src/delete_table.rs. On SQLite, #1411 also re-reads the status under the write lock (refuse_if_deleting_or_gone). This branch reads the row inside the BEGIN IMMEDIATE transaction under the same lock, so the re-read goes. #1411's two concurrent DeleteTable tests stay, in one test module with this branch's tests, and expect TableBeingDeleted. #1446 removes a MongoDB table's tags and catalog document in one transaction keyed on the table id (delete_tags_and_table_doc). This branch does the same in remove_deleting_document, which the control plane also runs. The merge keeps the branch's function and adds #1446's note on aws:ResourceTag to its comment. The live test live_delete_table_keeps_tags_while_deleting finishes its stopped DeleteTable with finish_table_delete, because this branch refuses a second DeleteTable. Other conflicts: the doc comment of ErrorMessageKey::TableBeingDeleted names both measurement dates. crates/engine/src/delete_table.rs keeps the key-info drop before the storage call with #1411's deleting_description, and one test module. The engine test uses main's crate::test_context, so crates/engine/src/partiql/test_context.rs is main's. In put_item.rs, delete_item.rs and update_item.rs the queries take main's AssertSqlSafe and keep this branch's db_error. In table_snapshot.rs, conftest.py and test_table_operations.py main's test names and helpers stay, with the TableBeingDeleted variant. In docs/differences-from-dynamodb.md both rows stay. #1411's row now says that MongoDB and Cassandra refuse a second DeleteTable too. sqlx 0.9.1 (#1166) refuses a query string built at run time. Eight of this branch's queries now take AssertSqlSafe: two in ddl.rs (table_key_info and the status check) and six in the window tests.
…e DELETING window Three answers of the window change, and the tests cover the dropped-table handling of UpdateItem and DeleteItem. An index read whose index table is gone answered ValidationException "The table does not have the specified index" while the catalog row was still DELETING. #401's mapping reads a missing index table as a GSI delete. read_target_gone now reads the table's catalog row by id. A row that is DELETING or gone answers TableNotFound, as main did before this branch served the window. Any other row keeps IndexNotFound. The control plane skipped the drop while any session held a lock on the table's relations. The requests the window serves hold those locks too, so a stream of them held the drop off. drop_unless_held now probes twice, 50 ms apart, and skips the drop only when one transaction holds a lock at both probes. storage_holders returns the holders' transaction ids for that, and DeleteTable's reader probe reads them through it. The data plane read a restore target that abort_restore claimed as not found only when the claim's transition time was the epoch. v1.0.0 and v1.1.0 write NOW(). DATA_PLANE_STATUS now reads a DELETING row whose table_restores row is not DONE as the CREATING target it was. So the data plane reads every release's claim the same way, and abort_restore writes NOW() again. The db_error mappings in put_item.rs, delete_item.rs and update_item.rs go back to main's text. data_table_missing matches the relation name in the message, so they did not change an answer.
PostgreSQL and SQLite answer table_key_info for a DELETING row, and the key-info cache kept that entry like any other. Then another server removed the table and created the name again. A server that read the table in its window kept the removed table's id. Its requests on the new table answered ResourceNotFoundException until the entry expired. The loader now reads the status of a found table with describe_table. get serves an entry read as DELETING once and drops it, so the next read loads again. A failed status read gets the same treatment. The cost is one describe_table per load, not per request.
…'s last delete step On SQLite, a test now sends Query and Scan after it drops the data table under a DELETING row: both answer TableNotFound. On MongoDB, the late second run of a delete now also meets a new table of the name that is itself DELETING. There only the table id in the last delete_one's filter tells the two documents apart. The new table's document, collections and tag stay.
The check after the table is gone was a GetItem on a name that no longer exists, which fails whether or not the write survived. The test now creates a table under the name again and reads the key the window wrote: the new table does not have it.
Several texts said that the service serves the data plane until the table is gone. They are the differences row, the key-info comments in both ddl.rs files, and the headers of the window tests. The service serves it for the first part of the window only. Single-item reads and writes, Query and Scan are served for the first 2.7 to 5.7 s of a 6.4 to 8.1 s window. The batch, transaction and PartiQL calls are served for the first 0.5 to 2.1 s. After that the service answers ResourceNotFoundException while DescribeTable still reads DELETING (measured 2026-11-27). Each text now says so, and that ExtendDB serves the whole window. The upgrade manual gets a v1.2.0 entry for the window's answers. #1411's v1.2.0 entry said that MongoDB and Cassandra answer a second DeleteTable of a DELETING table with 200. They refuse it with this branch, and the sentence now points to the new entry.
…affic test With two sessions the test passed with the old single probe too, so it did not show that the drop goes ahead. A request now starts every 10 ms and holds the data table for 40 ms, on worker threads of their own. With the old probe the table is still DELETING 5 s after the reader's release, 2 of 2 runs. With the second probe it is dropped 0.19 to 0.26 s after the release, 3 of 3 runs.
|
LJMart11
left a comment
There was a problem hiding this comment.
Checked at a2cae34 against the list from 9cbb9fe.
The follow-up reads a DELETING restore target by its table_restores row instead of its transition time, answers an index read on a DELETING or removed table as TableNotFound, and serves a DELETING key-info entry once without caching it. Confirmed: a DELETING row claimed with status_transition_at = NOW() and a RUNNING or FAILED restore record answers TableNotFound from table_key_info and index_info, and a DONE one is served; the deleting_window target passed 10 of 10 on PostgreSQL 16 under Rust 1.94.0. The storage-postgres, server, engine and storage-sqlite test targets passed 2377 tests with 0 failures. The base tip equals the prior merge point (c057660), so the merged tree is this head.
Previous items: 1 fixed.
Main is at 5826e1b, three commits past c057660: #1531, #1466 and #1087. In docs/manuals/07-upgrade-manual.md, #1531 adds a v1.2.0 entry at the top of "Behavior Changes by Release", and git merged it with no conflict. #1087 adds its v1.2.0 entry after the other v1.2.0 entries of main, where this branch has its entry. That is the one conflict. The merge keeps both entries without change: the entry of #1087 first, then the entry of this branch, before the v1.1.0 entries. Git merged three other files with no conflict: - crates/storage-sqlite/src/data/data_engine.rs: #1087 changes scan_key_in_segment to compute the segment from the key, with no read of the data table. This branch maps the error of a dropped data table to StorageError::TableNotFound in the other data-plane calls, and it does not change scan_key_in_segment. - crates/storage-sqlite/src/lib.rs: #1087 declares the scan_segment_tests module, and this branch declares deleting_window_data_tests. - crates/storage-cassandra/tests/direct_integration.rs: #1531 declares the update_item_retry module, and this branch declares deleting_window.
|
Checked at Fixed:
Disputed: none. Needs-human: none. |
…eeps (ExtendDB#1411) * fix(engine): describe a DELETING table with the members the service keeps While a table is DELETING, DeleteTable's 200 and DescribeTable on the service carry no KeySchema, AttributeDefinitions, CreationDateTime, WarmThroughput, GlobalSecondaryIndexes, LocalSecondaryIndexes or VectorIndexes. ExtendDB sent all of them on every backend, and DeleteTable on Cassandra sent TableStatus ACTIVE, the status the row had before the delete. The service keeps TableName, TableArn, TableId, TableStatus, TableSizeBytes, ItemCount, ProvisionedThroughput, DeletionProtectionEnabled and, when the table has them, BillingModeSummary, TableThroughputModeSummary, TableClassSummary, SSEDescription, OnDemandThroughput, StreamSpecification, LatestStreamArn and LatestStreamLabel. Measured in us-east-1 on 2026-11-23 on on-demand and provisioned tables, with and without a GSI, an LSI, a vector index, a stream, a table class, KMS encryption and an on-demand throughput cap, at least twice each. TableDescription::prepare_for_response, which every path that returns a description runs, now empties those members for a DELETING table, and the three that are not optional skip serialisation when empty or zero. handle_delete_table sets the status to DELETING before it, so a backend that read the row before the delete answers as the others do. Later in the window the service sends less: first without StreamSpecification, then only ItemCount, ProvisionedThroughput, TableArn, TableName, TableSizeBytes and TableStatus. Neither stage is reproduced; the new row of docs/differences-from-dynamodb.md says so. The tests that asserted a KeySchema in a DELETING answer lose that assertion. Built on SQLite, PostgreSQL and MongoDB, the member sets of DeleteTable's answer equal the service's for each of those tables. Closes ExtendDB#602 Signed-off-by: Hitesh Sharma <hts@amazon.com> * fix(storage): refuse DeleteTable of a DELETING table as DynamoDB does A second DeleteTable on a table that is already DELETING answered 200 with the table's description on PostgreSQL and SQLite, following the API reference ("no error is returned"). Amazon DynamoDB refuses it: 400 ResourceInUseException "Attempt to change a resource which is still in use: Table is being deleted: <name>" (measured 2026-11-30 in us-east-1, 3 of 3 calls; the review of ExtendDB#1411 measured 2 of 2). Both backends now answer that refusal and change nothing; the control plane still finishes the delete. MongoDB keeps finishing a delete that an earlier DeleteTable left DELETING, since it has no worker that would; Cassandra never leaves a table DELETING. The differences doc gets a row for both. The pytest and the PostgreSQL storage tests that expected the 200 now expect the refusal, and the table fixture's teardown waits out a table the test already deleted instead of waiting for it to turn ACTIVE. Signed-off-by: Hitesh Sharma <hts@amazon.com> * fix(storage-sqlite): check DeleteTable's DELETING status under the write lock The DELETING refusal tested a row read before the write lock, so concurrent DeleteTables on one table all saw ACTIVE and all answered 200, where DynamoDB and PostgreSQL refuse all but one. Re-read the status inside the BEGIN IMMEDIATE transaction: a DELETING table is refused, and a table another call already removed is TableNotFound. Two tests run ten DeleteTables at once, with and without a control-plane delay, and fail without the check (ten successes). Signed-off-by: Hitesh Sharma <hts@amazon.com> * docs(upgrade): note DeleteTable's refusal and the DELETING description List the two client-visible changes from v1.1.0 under Behavior Changes by Release: a second DeleteTable on a DELETING PostgreSQL or SQLite table answers 400 ResourceInUseException, and DeleteTable's answer and a DELETING DescribeTable drop seven members. Signed-off-by: Hitesh Sharma <hts@amazon.com> * test(wasm): expect no WarmThroughput in a DELETING DeleteTable answer The parity corpus from ExtendDB#1009 checked that DeleteTable's answer carries the table's WarmThroughput. This change drops WarmThroughput from a DELETING description, as the service does, so the case now checks that the member is absent. Signed-off-by: Hitesh Sharma <hts@amazon.com> * refactor(core): build the Table is being deleted message once Add ErrorMessageKey::TableBeingDeleted (the name ExtendDB#550 uses) and build the refusal of a second DeleteTable from it on PostgreSQL and SQLite. Signed-off-by: Hitesh Sharma <hts@amazon.com> * fix(core): omit CreationDateTime only for a DELETING table The member skipped serialisation whenever it was 0.0, so an ACTIVE table whose stored creation time a backend could not read lost it. Make it an Option that prepare_for_response sets to None for a DELETING table, and send every other status's value as before. Signed-off-by: Hitesh Sharma <hts@amazon.com> * docs: correct the DeleteTable refusal entry and differences row Head the upgrade entry v1.2.0. With a control-plane delay below 1 the first DeleteTable removes the table on SQLite (and on PostgreSQL with one shared database and no reader), so concurrent calls answer ResourceNotFoundException, not the 400. A failed Cassandra restore target is DELETING while the reconciler removes it, and a DeleteTable then answers 200. Signed-off-by: Hitesh Sharma <hts@amazon.com> * test(pytest): share the DELETING backend check and list VectorIndexes Factor the backend detection of the two DELETING tests into one helper, fix a docstring that named the test's old name, and list VectorIndexes among the members a DELETING description drops. Signed-off-by: Hitesh Sharma <hts@amazon.com> * test: say when MongoDB and Cassandra hold a table DELETING MongoDB also leaves a table DELETING after a DeleteTable that stopped part-way. Cassandra holds one only while the restore reconciler removes a failed restore target. Wording from the review of ExtendDB#1411. Signed-off-by: Hitesh Sharma <hts@amazon.com> --------- Signed-off-by: Hitesh Sharma <hts@amazon.com> Co-authored-by: Hitesh Sharma <hts@amazon.com>
Main is at 1e2ebdd, eight commits past 5826e1b: #768, #1296, #1485, #1228, #1325, #1443, #1269 and the squash commit of #1093. Three files conflicted, in four hunks. In each hunk the UpdateTable window of #1093 meets the answer of this branch for a DELETING table: - crates/storage-postgres/src/update_table.rs and crates/storage-sqlite/src/update_table.rs have one hunk each. #1093 reads three more columns of the table row: the stored throughput, the table class and the window (in_window on PostgreSQL, stored_transition_at on SQLite). This branch answers a DELETING table with TableBeingDeleted right after UpdateTable reads the row. The merge keeps the wider read of #1093, then the DELETING check of this branch, then the check for a status other than ACTIVE. The window checks of #1093 come after that check, as on main. - crates/storage-mongodb/src/table_engine.rs has two hunks, both in require_active_table. #1093 makes the function return the catalog document of the table, and UpdateTable reads the window from it. This branch answers DELETING with TableBeingDeleted in a match on the status. The merge keeps that match, and its ACTIVE arm returns the document. The doc comment names the document and the three answers. A table has one stored status. #1093 reports UPDATING only for a stored ACTIVE table whose status_transition_at is later than now (reported_status in crates/storage/src/util/mod.rs). So no table is UPDATING and DELETING at the same time, and the merge does not choose between the two answers. Git merged six other files of this branch with no conflict: - crates/engine/src/update_table.rs: #1093 changes the doc comment of handle_update_table and declares the status_tests module. This branch maps TableBeingDeleted in update_table_err_to_dynamo. - crates/storage-cassandra/src/update_table.rs: #1093 reads status_transition_at and adds the window. This branch adds the same DELETING check before the check for a status other than ACTIVE. - crates/storage-postgres/tests/table_snapshot.rs: #1093 writes CREATING instead of UPDATING in two fixtures. This branch changes other tests. - crates/storage/src/error.rs: #1093 adds a sentence to the doc comment of IndexesInUse, and this branch adds TableBeingDeleted. - docs/differences-from-dynamodb.md: #1443 changes the default delay to 0.25 s, and #1093 changes the row on stream disable and the row of the delay setting. This branch adds the row on requests during a DELETING window. - docs/manuals/07-upgrade-manual.md: #1093 adds its v1.2.0 entry at the top of "Behavior Changes by Release". The entry of this branch stays after the v1.2.0 entries of main. The change of this branch to the entry of #1411 stays too.
Changes since the last review
LJMart11 reviewed a2cae34 on 3 Dec. Two commits come after that review:
74429ba merges main at 5826e1b, which brings fix(storage-cassandra): retry a lost UpdateItem version check over the PutItem and DeleteItem window #1531, ci(release): add devtools/freeze-migrations #1466 and fix(storage-sqlite): keep each partition key in one parallel Scan segment #1087. In
docs/manuals/07-upgrade-manual.md, fix(storage-cassandra): retry a lost UpdateItem version check over the PutItem and DeleteItem window #1531 adds a v1.2.0 entry at the top of "Behavior Changes by Release", and git merged it with no conflict. fix(storage-sqlite): keep each partition key in one parallel Scan segment #1087 adds its v1.2.0 entry after the other v1.2.0 entries of main, where this branch has its entry. That is the one conflict. The merge keeps both entries without change: the entry of fix(storage-sqlite): keep each partition key in one parallel Scan segment #1087 first, then the entry of this branch, above the v1.1.0 entries. Git merged three other files with no conflict:crates/storage-sqlite/src/data/data_engine.rs: fix(storage-sqlite): keep each partition key in one parallel Scan segment #1087 changesscan_key_in_segmentto compute the segment from the key, with no read of the data table. This branch maps the error of a dropped data table toStorageError::TableNotFoundin the other data-plane calls, and it does not changescan_key_in_segment.crates/storage-sqlite/src/lib.rs: fix(storage-sqlite): keep each partition key in one parallel Scan segment #1087 declares thescan_segment_testsmodule, and this branch declaresdeleting_window_data_tests.crates/storage-cassandra/tests/direct_integration.rs: fix(storage-cassandra): retry a lost UpdateItem version check over the PutItem and DeleteItem window #1531 declares theupdate_item_retrymodule, and this branch declaresdeleting_window.The lines that this branch changes against main are the same before and after the merge. The gates on 74429ba:
cargo +1.97.0 fmt --all -- --checkand the two clippy commands of.github/workflows/clippy.ymlwith-D warnings, on the whole workspace as CI runs them: clean.extenddb-core1260 passed and 1 ignored,extenddb-engine984,extenddb-server523,extenddb-storage296,extenddb-storage-sqlite344 and 1 ignored,extenddb-storage-postgres93,extenddb-storage-mongodb206 and 86 ignored,extenddb-storage-cassandra194. The MongoDB run used a replica set. The seven backup tests of storage-sqlite: the two write_lock_tests fail when an ancestor of the Cargo target directory is owned by another user #1414 fail on this host, as at a2cae34.cargo test -p extenddb-wasm-adapter: 4 passed, with theparitycorpus test.cargo test -p extenddb-storage-postgres --test doc_version_literals: 3 passed.tests/test_table_operations.pypassed 30 tests on each. On PostgreSQL, with the admin connection string and the catalog database name set,tests/python/test_deleting_window_control_plane.pyandtests/test_table_operations.py::TestDeleteTablepassed 12 tests. On SQLite the 5 tests of the window file skipped, because the file holds the window through PostgreSQL only.tests/test_query_scan.py,tests/test_scan_segments.py,tests/test_read_paging.py,tests/python/test_query_scan.pyandtests/python/test_scan_edge_cases.pypassed 220 tests on each server.python3 -m pytest --collect-only -qcollects 7346 tests intests/and 825 intests/pythonwith no error.3d882d0 merges main at 1e2ebdd, which brings fix(bin): rerun the build script when the checked-out commit changes #768, fix(server): ignore a TableName sent to an operation without one #1296, docs: correct the throttle bucket key and the LSI plan limits #1485, fix(core): list the pattern clause for an empty name member #1228, fix(console): serve the pages under a Content-Security-Policy that runs no inline script #1325, docs: fix stale defaults and duplicate headings outside install pages #1443, test(storage-cassandra): widen the timing bounds of two lock tests #1269 and fix: answer UPDATING while an UpdateTable change applies #1093. fix: answer UPDATING while an UpdateTable change applies #1093 answers
UPDATINGwhile anUpdateTablechange applies, and refuses a second capacity change in that time. Three files conflicted, in four hunks. In each hunk theUpdateTablewindow of fix: answer UPDATING while an UpdateTable change applies #1093 meets this branch's answer for aDELETINGtable:crates/storage-postgres/src/update_table.rsandcrates/storage-sqlite/src/update_table.rs, one hunk each. fix: answer UPDATING while an UpdateTable change applies #1093 reads three more columns of the table row: the stored throughput, the table class and the window (in_windowon PostgreSQL,stored_transition_aton SQLite). This branch answers aDELETINGtable withTableBeingDeletedright afterUpdateTablereads the row. The merge keeps the wider read of fix: answer UPDATING while an UpdateTable change applies #1093, then theDELETINGcheck of this branch, then the check for a status other thanACTIVE. The window checks of fix: answer UPDATING while an UpdateTable change applies #1093 come after that check, as on main.crates/storage-mongodb/src/table_engine.rs, two hunks inrequire_active_table. fix: answer UPDATING while an UpdateTable change applies #1093 makes the function return the table's catalog document, andUpdateTablereads the window from it. This branch answersDELETINGwithTableBeingDeletedin amatchon the status. The merge keeps thatmatch, and itsACTIVEarm returns the document. The doc comment names the document and the three answers.A table has one stored status, and fix: answer UPDATING while an UpdateTable change applies #1093 reports
UPDATINGonly for a storedACTIVEtable whosestatus_transition_atis later than now (reported_statusincrates/storage/src/util/mod.rs). So no table isUPDATINGandDELETINGat the same time, and the merge does not choose between the two answers. Git merged six other files of this branch with no conflict, each at other lines. They arecrates/engine/src/update_table.rs,crates/storage-cassandra/src/update_table.rs,crates/storage-postgres/tests/table_snapshot.rs,crates/storage/src/error.rs,docs/differences-from-dynamodb.mdanddocs/manuals/07-upgrade-manual.md. In the Cassandra file, this branch adds the sameDELETINGcheck before theACTIVEcheck. The entry of this branch stays after the v1.2.0 entries of main.Against main, the lines that this branch changes are the same before and after the merge, apart from
require_active_table: its doc comment and itsACTIVEarm. The gates on 3d882d0:cargo +1.97.0 fmt --all -- --checkand the two clippy commands of.github/workflows/clippy.ymlwith-D warnings, on the whole workspace as CI runs them: clean.extenddb-core1260 passed and 1 ignored,extenddb-engine988,extenddb-server526,extenddb-storage297,extenddb-storage-sqlite346 and 1 ignored,extenddb-storage-postgres93,extenddb-storage-mongodb206 and 87 ignored,extenddb-storage-cassandra194. The MongoDB run used a replica set. The seven backup tests of storage-sqlite: the two write_lock_tests fail when an ancestor of the Cargo target directory is owned by another user #1414 fail on this host, as at 74429ba. The tests of fix: answer UPDATING while an UpdateTable change applies #1093 in these crates pass:update_table::status_tests(4) in the engine,util::update_window_testsinextenddb-storageandtable_helpers::stored_value_tests(2) on SQLite.cargo test -p extenddb-wasm-adapter: 4 passed, with theparitycorpus test.cargo test -p 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=1andEXTENDDB_EXPECT_VECTORS=1: 510 passed and 2 ignored.deleting_window(10) and theupdate_table_windowtest of fix: answer UPDATING while an UpdateTable change applies #1093 pass. The five tests ofcheck_private_ancestorsfail on this host, as at a2cae34.cargo test --no-fail-fast -p extenddb-storage-sqlite --tests: 349 passed and 1 ignored. Four tests fail at the same host check of the backup root: the two of storage-sqlite: the two write_lock_tests fail when an ancestor of the Cargo target directory is owned by another user #1414,a_job_task_that_panics_leaves_a_row_the_next_cycle_resolves_without_a_restartintests/backup_job_panic.rsanda_dead_restore_is_resumed_by_one_cycle_from_its_recorded_progressintests/restore_job_resume.rs. This branch and fix: answer UPDATING while an UpdateTable change applies #1093 do not change those files..github/workflows/integration-mongodb.yml:snapshot_engine12 passed, with a standalone server fora_standalone_server_is_unsupported.--lib deleting_window_tests9 passed. Every test target withEXTENDDB_TEST_MONGODB_REQUIRED=1: 291 passed and 87 ignored.--ignored --test-threads=1 data_engine::live_tests::: 22 passed, theupdate_windowtest of fix: answer UPDATING while an UpdateTable change applies #1093 among them.EXTENDDB_TEST_CASSANDRA=required),--features test-hooks --test direct_integrationwith the modulestable_engine,stream_disableanddeleting_window: 9 passed.tests/python/test_deleting_window_control_plane.pyandtests/test_table_operations.pypassed 35 tests on PostgreSQL. That run set the admin connection string and the catalog database name. On SQLite 30 passed, and the 5 tests of the window file skipped, because the file holds the window through PostgreSQL only. The wire files of fix: answer UPDATING while an UpdateTable change applies #1093,tests/python/test_update_table_status.py,test_stream_disable.pyandtest_warm_throughput_updates.py, passed 61 tests on each server, and 4 tests oftest_stream_disable.pyxfailed at its marker for End GetRecords iterators after closed shard exhaustion #372.python3 -m pytest --collect-only -qcollects 7408 tests intests/and 863 intests/pythonwith no error.These commits answer the reviews of 27 Nov by LJMart11 and demohan:
DeleteTablepaths. The merge keeps one check per backend, throughStorageError::TableBeingDeleted. See "Conflicts with main".TableNotFoundwhen the table's row isDELETINGor gone. The control plane drops aDELETINGtable while requests are served. The data plane reads a restore target that any release claimed for removal as not found. Thedb_errormappings input_item.rs,delete_item.rsandupdate_item.rsgo back to main's text.DELETINGtable's entry once and does not keep it.QueryandScanafter the data drop, and MongoDB's last delete step on a newDELETINGtable of the name. The wire file reads the window write through a table created again under the name.The messages of two pushed commits are no longer true at this head. 4b7389a gives the data plane's answers in the window as measured on the service, where the service serves it for the first seconds only. It also names a TTL error mapper arm and a wire-test skip, which cd5b930 and 657e1c0 dropped. 040be0d describes the epoch claim that a1e2494 replaces. Whoever merges: please use the What section of this body as the squash message.
What
While a table is
DELETING, ExtendDB answered requests differently from Amazon DynamoDB (#505). A secondDeleteTableand anUpdateTablereported the table as absent or with the wrong sentence. The data plane refused reads and writes that the service serves.StorageError::TableBeingDeletedis new. The engine's message table words it once (Attempt to change a resource which is still in use: Table is being deleted: <name>). One engine helper builds theResourceInUseExceptionfor theDeleteTableandUpdateTableerror mappers and for the tag refusal below.DeleteTableon PostgreSQL and SQLite answers aDELETINGrow withTableBeingDeleted, as main's fix(engine): describe a DELETING table with the members the service keeps #1411 also does. MongoDB'sDeleteTablerefuses aDELETINGdocument the same way, where main ran the removal again and answered 200. Cassandra'sDeleteTablenever marks the row. Its check covers only a restore target that the backup reconciler or its failed restore removes.DELETINGrow as found.PutItem,GetItem,Query,Scan,UpdateItem,DeleteItemand the batch and transaction calls are served for the whole window. A statement or transaction that reaches a data table the control plane has dropped answersResourceNotFoundException, where it answered a 500. On SQLite only a missing_ddb_<id>table counts, and a missing shared table such asstream_recordsstays an internal error.QueryorScanwithIndexName) that finds its index table gone reads the table's catalog row by id. A row that isDELETINGor gone answersTableNotFound, which isResourceNotFoundExceptionon the wire, as main answered. Any other row keeps fix(postgres): build a GSI added by UpdateTable correctly while writes continue #401'sIndexNotFound: a GSI delete that committed after the read resolved the index.DELETINGtable's relations twice, 50 ms apart. It skips the drop only when one transaction holds a lock at both probes: a snapshot, the backup, an index build orVACUUM. The requests served in the window hold their locks for one short transaction each, so they no longer hold the drop off. The drop waits for the requests in flight, and the requests after it queue behind its lock.DELETINGtable's entry to that caller and drops it, so the next read loads again. Before this, a server could read the table during the window while another server removed the table and created the name again. The first server then kept the removed table's id. That server's requests on the new table answeredResourceNotFoundExceptionuntil the entry expired. A failed status read gets the same treatment. The cost is onedescribe_tableper load, and a read served from the cache sends no extra query.QueryorScannames an index that does not resolve, the engine asks the catalog for the table again, uncached. A table that is gone isResourceNotFoundException, and the engine drops its entry. A table that still exists keeps theValidationException.DeleteTabledrops the table's key-info cache entry before the storage call as well as after it. On MongoDB the steps after theDELETINGmark run in a task that keeps running when the caller gives up. The second cache drop then never runs. An entry cached before theDeleteTablelet aPutItemcreate the dropped data collection again.TagResourceandUntagResourceon aDELETINGtable answerResourceInUseExceptionwith the sentence above, as the service does.ListTagsOfResourceis served. The tag handlers read the status withdescribe_table, since the key info carries none.abort_restoreremoves a restore target for the backup reconciler and for a failed restore, and claims it by marking itDELETING. The data plane reads aDELETINGrow whosetable_restoresrecord is notDONEas theCREATINGtarget it was. Such a target is not found, as before this change. A restore setsDONEonly in the transaction that makes its targetACTIVE. So the check holds for a claim that any release wrote, one withNOW()as its transition time too.DELETINGmark run in a task of their own that the request awaits. A client timeout does not cancel them. The control-plane worker finishes aDeleteTablewhose document is stillDELETING60 s after its mark (a step that failed, a process that died). Without this, the refusal of a secondDeleteTableleft such a tableDELETINGpermanently. The task and a control-plane pass can run the steps at once. So the last step removes the document and the tags in one transaction, and removes the tags only when it removed this table id'sDELETINGdocument. A table created into the name has the same ARN.DeleteTablecalls get one winner. SQLite's status lookup runs inside theBEGIN IMMEDIATEwrite transaction, which holds the row until the mark. MongoDB's mark is anupdate_oneconditioned on table id and status, and its finaldelete_oneis keyed on both. PostgreSQL holds the rowFOR UPDATE.Why
Closes #505. This also fixes the
TagResourceandUntagResourcerows of #551, and itsListTagsOfResourcerow on PostgreSQL and SQLite. On MongoDB,ListTagsOfResourceduring the window still answersResourceNotFoundException.Each control-plane answer was measured on the service on 2026-10-24 and 2026-10-25, with the window held open by a lock on the data table. The tag answers were measured on 2026-11-03. The service serves the data plane for the first part of the window only (demohan's measurement of 2026-11-27, which this round did not send again). Single-item reads and writes,
QueryandScanwere served for the first 2.7 to 5.7 s of a 6.4 to 8.1 s window. The batch, transaction and PartiQL calls were served for the first 0.5 to 2.1 s. After that they answeredResourceNotFoundExceptionwhileDescribeTablestill readDELETING. ExtendDB serves the whole window.docs/differences-from-dynamodb.mdlists that as a difference, and #1565 tracks it.Per backend
DeleteTable,UpdateTableResourceInUseException, the sentence aboveResourceNotFoundExceptionResourceNotFoundException)ResourceNotFoundExceptionon a cold cache. The collections normally drop inside theDeleteTablecall milliseconds after the mark. A delete that waits on a lock or stops staysDELETINGuntil it is finished, and the table is not served meanwhileDeleteTablenever writesDELETING)On PostgreSQL the row is
DELETINGwhenDeleteTableleaves the drop to the control plane. That happens withcontrol_plane_delay_secondsof 1 or more, and at any delay while another session holds a lock on one of the table's relations. With a separate data database, the immediate path that #504 added also marks the rowDELETING. The row staysDELETINGfrom its catalog commit until it goes after its data commit. On SQLite the row isDELETINGon the asynchronousDeleteTablepath (control_plane_delay_secondsof 1 or more, where the default is 0.25).Measured, not changed here
UpdateTimeToLiveduring the window: service 200, ExtendDBResourceInUseException.DescribeTimeToLive: serviceCannot describe time to live while table is in DELETING state: Current table state is DELETING, ExtendDB 200. fix: answer TTL and tag calls during a table's DELETING window #599 changes both.DeleteTablecalls on Cassandra both complete, since the backend never writesDELETING. fix(cassandra): fence concurrent DeleteTable with a lease #598 changes that.ExecuteTransactionanswers plainResourceNotFoundExceptionon PostgreSQL, where main answeredTransactionCanceledExceptionwithResourceNotFound. demohan's runs on the service gave both answers.DeleteTableand theDELETINGmark stores theACTIVEentry. APutItemwith it after the data collection is dropped creates the collection again, with no catalog document left to name it. Closing it needs a change to the MongoDB write path or to the cache, filed as MongoDB: a key-info entry cached during DeleteTable can create the dropped data collection again #1440.Conflicts with main
b7d46a8 merges main at c057660. Main's #1411 refuses a second
DeleteTableof aDELETINGtable on PostgreSQL and SQLite. #1446 removes a MongoDB table's tags and catalog document in one transaction keyed on the table id. This branch does both in its own way, so the merge keeps one copy of each:crates/storage-postgres/src/delete_table.rsandcrates/storage-sqlite/src/delete_table.rs: fix(engine): describe a DELETING table with the members the service keeps #1411 refuses withStorageError::IndexesInUseand the message, this branch withStorageError::TableBeingDeleted, whichUpdateTable, MongoDB and Cassandra raise too. The merge keeps the variant. It removes the second check that git placed after this branch's check on PostgreSQL, and fix(engine): describe a DELETING table with the members the service keeps #1411'sdeleting_refusalandrefuse_if_deleting_or_goneon SQLite. This branch reads the SQLite row inside theBEGIN IMMEDIATEtransaction, so the re-read under the lock has no work left. fix(engine): describe a DELETING table with the members the service keeps #1411's two concurrentDeleteTabletests stay, in one module with this branch's tests, and expectTableBeingDeleted.crates/storage-mongodb/src/table_engine.rs: the merge keeps this branch'sremove_deleting_document, which the control plane also runs, in place of fix(storage-mongodb): keep a DELETING table's tags until its document goes #1446'sdelete_tags_and_table_doc, and adds fix(storage-mongodb): keep a DELETING table's tags until its document goes #1446's note onaws:ResourceTagto its comment. fix(storage-mongodb): keep a DELETING table's tags until its document goes #1446's live testlive_delete_table_keeps_tags_while_deletingfinishes its stopped delete withfinish_table_delete, because a secondDeleteTableis refused here.crates/core/src/error/messages.rs: both added the sameTableBeingDeletedkey and message, and its comment names both measurement dates.crates/engine/src/delete_table.rskeeps the key-info drop before the storage call with fix(engine): describe a DELETING table with the members the service keeps #1411'sdeleting_description, in one test module. The engine test uses main'scrate::test_context, socrates/engine/src/partiql/test_context.rsis main's.put_item.rs,delete_item.rsandupdate_item.rsthe queries take main'sAssertSqlSafe, and a1e2494 puts back main's error mapping.crates/storage-postgres/tests/table_snapshot.rs,tests/conftest.pyandtests/test_table_operations.py, main's test names and helpers stay, with theTableBeingDeletedvariant.docs/differences-from-dynamodb.mdboth rows stay. fix(engine): describe a DELETING table with the members the service keeps #1411's row now says that MongoDB and Cassandra refuse a secondDeleteTabletoo, and b6ba507 changes fix(engine): describe a DELETING table with the members the service keeps #1411's upgrade-manual entry the same way.AssertSqlSafe: two inddl.rs(table_key_infoand the status check) and six in the window tests.3d882d0 merges main at 1e2ebdd, where #1093 changes
UpdateTableon every backend. "Changes since the last review" gives its four conflict hunks.Rebase on #401
On PostgreSQL #401 answers
TableNotFoundfor a statement that reaches a dropped data table, as this branch did. The branch keeps #401's three helpers indata/data_engine.rs(table_gone,read_target_gone,table_gone_among).read_target_gonenow reads the catalog row, as "What" says.data_table_missingmatches theSQLSTATE 42P01prefix and the relation name in the message, soput_item.rs,delete_item.rsandupdate_item.rskeep main's error mapping.Rebase on #395
#395 made
DeleteTableof a table that is alreadyDELETINGreturn the table's description on PostgreSQL and SQLite. The service refuses that request. On 2026-10-30 a secondDeleteTableanswered 400ResourceInUseExceptionAttempt to change a resource which is still in use: Table is being deleted: <name>in 12 of 12 runs. The runs used empty tables and tables of 300 items, from at once to 3 s after the first call, whileDescribeTablereportedDELETING. That agrees with the 2026-10-25 runs above and with #1411's of 2026-11-30. Main's tests of that answer (delete_table_of_a_deleting_table_is_refused,an_open_held_with_deletes_queued_completes,test_delete_of_a_deleting_table_is_refused) keep their names here and expectTableBeingDeleted.The troubleshooting entry for a table stuck in
DELETINGsays the same.Overlaps with other PRs
refuse_unless_activeto the PostgreSQLUpdateTablestatus check, which this PR gives aDELETINGarm inupdate_table.rs. The second of the two to merge puts theDELETINGarm insiderefuse_unless_active. Otherwise fix(postgres): refuse UpdateTable on a non-ACTIVE table without the row lock #569's unlocked pre-read answersTableNotActivefor aDELETINGtable before this PR's check runs. Since fix: answer UPDATING while an UpdateTable change applies #1093 merged, fix(postgres): refuse UpdateTable on a non-ACTIVE table without the row lock #569 conflicts with main in that file too.UpdateTableon every backend. "Changes since the last review" gives what the merge 3d882d0 keeps.DeleteTablepaths. "Conflicts with main" gives what the merge keeps.Testing done
At a2cae34, 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-engine984,extenddb-server523,extenddb-storage295,extenddb-storage-sqlite343 and 1 ignored,extenddb-storage-postgres93,extenddb-storage-mongodb206 and 86 ignored,extenddb-storage-cassandra192. The MongoDB run used the replica set, so itsdeleting_window_tests(9) 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: 509 passed and 2 ignored,deleting_window(10) 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: 3 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: 12 passed on PostgreSQL. On SQLite the 7TestDeleteTabletests passed, and the 5 tests of the window file skipped, because the file holds the window through PostgreSQL only.python3 -m pytest --collect-only -qoftests/(7309 tests) and oftests/python(825): no error.Controls, each with the tests kept and the guard's production lines put back. Each test fails:
an_index_read_after_the_drop_is_table_not_foundwith the oldIndexNotFoundmapping.served_requests_do_not_hold_off_the_dropwith the old single probe: stillDELETING5 s after the reader's release, 2 of 2 runs. With the fix the row was gone 0.19 to 0.26 s after the release, 3 of 3.a_restore_target_claimed_by_an_earlier_release_is_not_foundwith the epoch classifier, and with the status check offetch_index_inforemoved.a_request_after_the_data_drop_is_table_not_foundon PostgreSQL without the funnel onupdate_itemanddelete_item, and on SQLite without the funnel onqueryandscan.a_deleting_entry_is_served_once_and_not_keptwith the entry kept, anda_deleting_table_is_served_and_markedwith the entry never marked.a_late_second_run_of_a_delete_leaves_a_new_table_of_the_name_wholeon MongoDB without thetable_idkey of the lastdelete_one.CI runs the PostgreSQL storage tests with
--tests, sodeleting_windowruns there with no list entry..github/workflows/integration-mongodb.ymlrunsdeleting_window_testsagainst the replica set. The round sent no request to DynamoDB.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. The PR adds a variant to
StorageErrorin the internalextenddb-storagecrate, which the engine maps to a wire error. No trait method changes.Breaking changes
A client sees the service's answers during the
DELETINGwindow, where it saw others. The upgrade manual's v1.2.0 entry gives them:DeleteTableanswersResourceInUseExceptionwithTable is being deleted: <name>, where main answered 200. PostgreSQL and SQLite answer it on main since fix(engine): describe a DELETING table with the members the service keeps #1411.UpdateTable,TagResourceandUntagResourceon aDELETINGtable answer that exception and sentence.ResourceNotFoundException.DeleteTablewhose document is stillDELETING60 s after its mark.No migration and no setting 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.