Skip to content

fix: answer requests during a table's DELETING window as the service does - #550

Open
LeeroyHannigan wants to merge 43 commits into
mainfrom
fix/505-deleting-window-answers
Open

LeeroyHannigan wants to merge 43 commits into
mainfrom
fix/505-deleting-window-answers

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

LJMart11 reviewed a2cae34 on 3 Dec. Two commits come after that review:

These commits answer the reviews of 27 Nov by LJMart11 and demohan:

  • b7d46a8 merges main at c057660. Thirteen files conflicted, because main's fix(engine): describe a DELETING table with the members the service keeps #1411 and fix(storage-mongodb): keep a DELETING table's tags until its document goes #1446 change the same DeleteTable paths. The merge keeps one check per backend, through StorageError::TableBeingDeleted. See "Conflicts with main".
  • a1e2494, on PostgreSQL. An index read whose index table is gone answers TableNotFound when the table's row is DELETING or gone. The control plane drops a DELETING table while requests are served. The data plane reads a restore target that any release claimed for removal as not found. The db_error mappings in put_item.rs, delete_item.rs and update_item.rs go back to main's text.
  • d9db9c4: the key-info cache serves a DELETING table's entry once and does not keep it.
  • 1159934 and bd6b452 add tests: SQLite Query and Scan after the data drop, and MongoDB's last delete step on a new DELETING table of the name. The wire file reads the window write through a table created again under the name.
  • b6ba507: the texts give the service's two phases of the window, and the upgrade manual gets a v1.2.0 entry.
  • a2cae34: the served-traffic test holds a lock at every instant.

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 second DeleteTable and an UpdateTable reported the table as absent or with the wrong sentence. The data plane refused reads and writes that the service serves.

  • StorageError::TableBeingDeleted is 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 the ResourceInUseException for the DeleteTable and UpdateTable error mappers and for the tag refusal below.
  • DeleteTable on PostgreSQL and SQLite answers a DELETING row with TableBeingDeleted, as main's fix(engine): describe a DELETING table with the members the service keeps #1411 also does. MongoDB's DeleteTable refuses a DELETING document the same way, where main ran the removal again and answered 200. Cassandra's DeleteTable never marks the row. Its check covers only a restore target that the backup reconciler or its failed restore removes.
  • The key-info read on PostgreSQL and SQLite reads a DELETING row as found. PutItem, GetItem, Query, Scan, UpdateItem, DeleteItem and 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 answers ResourceNotFoundException, where it answered a 500. On SQLite only a missing _ddb_<id> table counts, and a missing shared table such as stream_records stays an internal error.
  • On PostgreSQL, an index read (Query or Scan with IndexName) that finds its index table gone reads the table's catalog row by id. A row that is DELETING or gone answers TableNotFound, which is ResourceNotFoundException on the wire, as main answered. Any other row keeps fix(postgres): build a GSI added by UpdateTable correctly while writes continue #401's IndexNotFound: a GSI delete that committed after the read resolved the index.
  • On PostgreSQL, the control plane probes a due DELETING table'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 or VACUUM. 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.
  • The key-info cache reads the status of a table it loads. It serves a DELETING table'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 answered ResourceNotFoundException until the entry expired. A failed status read gets the same treatment. The cost is one describe_table per load, and a read served from the cache sends no extra query.
  • When a Query or Scan names an index that does not resolve, the engine asks the catalog for the table again, uncached. A table that is gone is ResourceNotFoundException, and the engine drops its entry. A table that still exists keeps the ValidationException.
  • DeleteTable drops the table's key-info cache entry before the storage call as well as after it. On MongoDB the steps after the DELETING mark run in a task that keeps running when the caller gives up. The second cache drop then never runs. An entry cached before the DeleteTable let a PutItem create the dropped data collection again.
  • TagResource and UntagResource on a DELETING table answer ResourceInUseException with the sentence above, as the service does. ListTagsOfResource is served. The tag handlers read the status with describe_table, since the key info carries none.
  • On PostgreSQL, abort_restore removes a restore target for the backup reconciler and for a failed restore, and claims it by marking it DELETING. The data plane reads a DELETING row whose table_restores record is not DONE as the CREATING target it was. Such a target is not found, as before this change. A restore sets DONE only in the transaction that makes its target ACTIVE. So the check holds for a claim that any release wrote, one with NOW() as its transition time too.
  • On MongoDB the steps after the DELETING mark run in a task of their own that the request awaits. A client timeout does not cancel them. The control-plane worker finishes a DeleteTable whose document is still DELETING 60 s after its mark (a step that failed, a process that died). Without this, the refusal of a second DeleteTable left such a table DELETING permanently. 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's DELETING document. A table created into the name has the same ARN.
  • Two concurrent DeleteTable calls get one winner. SQLite's status lookup runs inside the BEGIN IMMEDIATE write transaction, which holds the row until the mark. MongoDB's mark is an update_one conditioned on table id and status, and its final delete_one is keyed on both. PostgreSQL holds the row FOR UPDATE.

Why

Closes #505. This also fixes the TagResource and UntagResource rows of #551, and its ListTagsOfResource row on PostgreSQL and SQLite. On MongoDB, ListTagsOfResource during the window still answers ResourceNotFoundException.

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, Query and Scan were 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 answered ResourceNotFoundException while DescribeTable still read DELETING. ExtendDB serves the whole window. docs/differences-from-dynamodb.md lists that as a difference, and #1565 tracks it.

Per backend

second DeleteTable, UpdateTable data plane during the window
Service ResourceInUseException, the sentence above served for the first seconds, then ResourceNotFoundException
PostgreSQL, SQLite the same served for the whole window (was ResourceNotFoundException)
MongoDB the same ResourceNotFoundException on a cold cache. The collections normally drop inside the DeleteTable call milliseconds after the mark. A delete that waits on a lock or stops stays DELETING until it is finished, and the table is not served meanwhile
Cassandra the same, reachable only for a restore target that the backup reconciler or its failed restore removes unchanged (DeleteTable never writes DELETING)

On PostgreSQL the row is DELETING when DeleteTable leaves the drop to the control plane. That happens with control_plane_delay_seconds of 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 row DELETING. The row stays DELETING from its catalog commit until it goes after its data commit. On SQLite the row is DELETING on the asynchronous DeleteTable path (control_plane_delay_seconds of 1 or more, where the default is 0.25).

Measured, not changed here

  • UpdateTimeToLive during the window: service 200, ExtendDB ResourceInUseException. DescribeTimeToLive: service Cannot 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.
  • Two concurrent DeleteTable calls on Cassandra both complete, since the backend never writes DELETING. fix(cassandra): fence concurrent DeleteTable with a lease #598 changes that.
  • In the gap between the data drop and the row's removal, ExecuteTransaction answers plain ResourceNotFoundException on PostgreSQL, where main answered TransactionCanceledException with ResourceNotFound. demohan's runs on the service gave both answers.
  • On MongoDB one cache window remains, from the code and not measured. A key-info read between the first cache drop in DeleteTable and the DELETING mark stores the ACTIVE entry. A PutItem with 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 DeleteTable of a DELETING table 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:

3d882d0 merges main at 1e2ebdd, where #1093 changes UpdateTable on every backend. "Changes since the last review" gives its four conflict hunks.

Rebase on #401

On PostgreSQL #401 answers TableNotFound for a statement that reaches a dropped data table, as this branch did. The branch keeps #401's three helpers in data/data_engine.rs (table_gone, read_target_gone, table_gone_among). read_target_gone now reads the catalog row, as "What" says. data_table_missing matches the SQLSTATE 42P01 prefix and the relation name in the message, so put_item.rs, delete_item.rs and update_item.rs keep main's error mapping.

Rebase on #395

#395 made DeleteTable of a table that is already DELETING return the table's description on PostgreSQL and SQLite. The service refuses that request. On 2026-10-30 a second DeleteTable answered 400 ResourceInUseException Attempt 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, while DescribeTable reported DELETING. 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 expect TableBeingDeleted.

The troubleshooting entry for a table stuck in DELETING says the same.

Overlaps with other PRs

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 -- --check and the two clippy commands of .github/workflows/clippy.yml with -D warnings, on the whole workspace: clean. cargo +1.94.0 check --all-targets on extenddb-core, extenddb-engine, extenddb-server, extenddb-storage and the four backend crates: clean.
  • Lib tests: extenddb-core 1260 passed and 1 ignored, extenddb-engine 984, extenddb-server 523, extenddb-storage 295, extenddb-storage-sqlite 343 and 1 ignored, extenddb-storage-postgres 93, extenddb-storage-mongodb 206 and 86 ignored, extenddb-storage-cassandra 192. The MongoDB run used the replica set, so its deleting_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 in backup_store::tests of extenddb-server and two in backup_catalog::write_lock_tests of extenddb-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 the parity corpus test. The clippy step of .github/workflows/wasm.yml for wasm32-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 --tests on postgres:16 with EXTENDDB_TEST_PG_REQUIRED=1: 509 passed and 2 ignored, deleting_window (10) among them. Five tests fail at the refusal of check_private_ancestors, because another user owns an ancestor directory of the backup root on this host. They are store_identity::a_root_owned_by_another_catalog_is_unhealthy, store_identity::host_local_roots_under_one_label_leave_the_second_instance_unhealthy and store_identity::two_instances_on_one_empty_root_end_with_one_id in backup_restore, and a_store_backed_backup_and_restore_keep_key_names_that_hold_u0000_and_u0001 and items_restored_by_the_restore_job_reach_a_gsi_keyed_on_a_u0001_name in catalog_nul_backup_jobs.
  • extenddb-storage-mongodb --lib -- --ignored live_delete on the replica set: 2 passed.
  • extenddb-storage-cassandra --features test-hooks --test direct_integration deleting_window on cassandra:4.1 with PasswordAuthenticator and EXTENDDB_TEST_CASSANDRA=required: 3 passed.
  • tests/python/test_deleting_window_control_plane.py and tests/test_table_operations.py::TestDeleteTable, against servers built from this head on 127.0.0.1: 12 passed on PostgreSQL. On SQLite the 7 TestDeleteTable tests passed, and the 5 tests of the window file skipped, because the file holds the window through PostgreSQL only.
  • python3 -m pytest --collect-only -q of tests/ (7309 tests) and of tests/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_found with the old IndexNotFound mapping.
  • served_requests_do_not_hold_off_the_drop with the old single probe: still DELETING 5 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_found with the epoch classifier, and with the status check of fetch_index_info removed.
  • a_request_after_the_data_drop_is_table_not_found on PostgreSQL without the funnel on update_item and delete_item, and on SQLite without the funnel on query and scan.
  • a_deleting_entry_is_served_once_and_not_kept with the entry kept, and a_deleting_table_is_served_and_marked with the entry never marked.
  • a_late_second_run_of_a_delete_leaves_a_new_table_of_the_name_whole on MongoDB without the table_id key of the last delete_one.

CI runs the PostgreSQL storage tests with --tests, so deleting_window runs there with no list entry. .github/workflows/integration-mongodb.yml runs deleting_window_tests against the replica set. The round sent no request to DynamoDB.

Checklist

  • I have read CONTRIBUTING.md
  • All tests pass (cargo test --workspace)
  • Code is formatted (cargo fmt --check)
  • Clippy is clean (cargo clippy -- -W clippy::pedantic)
  • I have added or updated tests for new functionality
  • I have updated documentation if behavior changed
  • Breaking changes are noted below (if any)
  • If this changes the wire protocol, Storage trait, auth model, on-disk
    format, or public CLI surface, an RFC has been accepted or is linked
    below. Otherwise, an ADR captures the decision (link below).

ADR / RFC: n/a. The PR adds a variant to StorageError in the internal extenddb-storage crate, which the engine maps to a wire error. No trait method changes.

Breaking changes

A client sees the service's answers during the DELETING window, where it saw others. The upgrade manual's v1.2.0 entry gives them:

  • On MongoDB and Cassandra a second DeleteTable answers ResourceInUseException with Table 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, TagResource and UntagResource on a DELETING table answer that exception and sentence.
  • On PostgreSQL and SQLite, the data-plane requests of the window are served, where they answered ResourceNotFoundException.
  • On MongoDB the control plane finishes a DeleteTable whose document is still DELETING 60 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.

…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.
@LeeroyHannigan
LeeroyHannigan force-pushed the fix/505-deleting-window-answers branch from 360f822 to 5b4c9ff Compare October 30, 2026 10:30
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@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 robinnsc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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 in fetch_table_key_info.
  • None of the MongoDB deleting_window_tests run in CI: they're #[ignore] and the MongoDB workflow only runs snapshot_engine.
  • deleting_window_data_tests.rs:236 needs <crate>/../../target or an absolute CARGO_TARGET_DIR; snapshot_engine.rs:489 already derives the path from current_exe().
  • On SQLite the lookup now runs inside BEGIN IMMEDIATE, so the rows_affected() == 0 arm 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 {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this 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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 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" => {}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 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:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 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) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This 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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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".

Comment thread tests/test_table_operations.py Outdated
)

def test_delete_of_a_deleting_table_returns_its_description(
def test_delete_of_a_deleting_table_is_refused_as_being_deleted(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 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,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 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 LJMart11 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread crates/storage-postgres/src/data/ddl.rs Outdated
/// `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' \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 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 demohan self-assigned this Nov 27, 2026

@demohan demohan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

hitesh96db pushed a commit that referenced this pull request Dec 2, 2026
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.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@demohan

  1. Main. b7d46a8 merges main at c057660. Thirteen files conflicted, because fix(engine): describe a DELETING table with the members the service keeps #1411 and fix(storage-mongodb): keep a DELETING table's tags until its document goes #1446 change the same DeleteTable paths. The merge keeps one check per backend, through StorageError::TableBeingDeleted. On SQLite it does not keep fix(engine): describe a DELETING table with the members the service keeps #1411's deleting_refusal and refuse_if_deleting_or_gone, because this branch reads the row inside the BEGIN IMMEDIATE transaction. On MongoDB it keeps this branch's remove_deleting_document in place of fix(storage-mongodb): keep a DELETING table's tags until its document goes #1446's delete_tags_and_table_doc, with fix(storage-mongodb): keep a DELETING table's tags until its document goes #1446's note on aws:ResourceTag. The sqlx 0.9.1 refusals are fixed: eight queries take AssertSqlSafe, ddl.rs (table_key_info and the status check) among them.

  2. Index reads in the PostgreSQL gap (data_engine.rs:469). Fixed in a1e2494. read_target_gone now reads the table's catalog row by id when an index read finds its index table gone. A row that is DELETING or gone answers TableNotFound, which reaches the client as ResourceNotFoundException, as main answered. Any other row keeps IndexNotFound for a GSI delete that committed after the index was resolved. an_index_read_after_the_drop_is_table_not_found drops the data tables under the DELETING row and sends Query and Scan on gsi1. With the row set back to ACTIVE, both answer IndexNotFound. With the old mapping put back, the test fails. ExecuteTransaction in the gap stays as it is: you measured both answers on the service, and the round did not send them again.

  3. Served traffic and the drop: see the reply in the thread on ddl.rs:382 (a1e2494, a2cae34).

  4. The second server's cache (key_info_cache.rs:163). Fixed in d9db9c4. The key-info loader now reads a found table's status with describe_table. get serves an entry read as DELETING once and drops it, so the next read loads again. A server that read the table in its window then loads the table created into the name once the old one is gone. A failed status read gets the same treatment. The cost is one describe_table per load. A read served from the cache sends no extra query. a_deleting_entry_is_served_once_and_not_kept loads the DELETING entry and then the new table, and the third read is a cache hit. With the entry kept, the second read answers the old table's id and the test fails.

  5. The tests on the dropped-table handling (data_engine.rs:1). Each test fails without its guard:

    • SQLite Query and Scan after the data drop answer TableNotFound (1159934).
    • PostgreSQL UpdateItem and DeleteItem rows join a_request_after_the_data_drop_is_table_not_found (a1e2494). The guard is the funnel in data_engine.rs. The 14 db_error mappings did not change an answer, because data_table_missing also matches the relation name in the message, so they go back to main's text.
    • The status check of fetch_index_info is now covered by index_info rows in a_restore_target_claimed_by_an_earlier_release_is_not_found.
    • MongoDB's a_late_second_run_of_a_delete_leaves_a_new_table_of_the_name_whole now also runs with the new table DELETING. There only the table_id key of the last delete_one keeps its document and tag.
  6. The two phases. Fixed in b6ba507 and d9db9c4. The differences row, the comments in both ddl.rs files and in key_info_cache.rs, and the window tests' headers now give the two phases you measured on 2026-11-27. They also say that ExtendDB serves the whole window, which The data plane is served for the whole DELETING window, where DynamoDB answers ResourceNotFoundException after the first seconds #1565 tracks. The round did not send those requests again. The upgrade manual gets a v1.2.0 entry for the window, and fix(engine): describe a DELETING table with the members the service keeps #1411's entry no longer says that MongoDB and Cassandra answer a second DeleteTable with 200.

@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@LJMart11 The finding is fixed in a1e2494. The data plane now keys a restore claim on its table_restores record, so a claim that v1.0.0 or v1.1.0 wrote with NOW() is not found. The reply in the thread on ddl.rs:41 gives the test and its control. The branch also merges main at c057660 (b7d46a8).

@LJMart11 LJMart11 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.
@LJMart11

LJMart11 commented Dec 4, 2026

Copy link
Copy Markdown

Checked at a2cae34 against the list from 9cbb9fe. The head moved again to 74429ba; this reviewer stops after two rounds and leaves the rest to a person.

Fixed:

  • item 1

Disputed: none.

Needs-human: none.

parsnips pushed a commit to parsnips/extenddb that referenced this pull request Dec 4, 2026
…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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1 Needed for the 1.0 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Requests during a table's DELETING window answer differently from DynamoDB

5 participants