Repository navigation
fix(engine): refuse DeleteTable on a table that is still CREATING - #1329
LeeroyHannigan wants to merge 9 commits into
Conversation
DynamoDB refuses DeleteTable on a table that CreateTable is still creating. It answers ResourceInUseException "Attempt to change a resource which is still in use: Table is being created: <name>". It gives the same answer for a table with deletion protection, and the table stays CREATING (measured in us-east-1 on 2026-11-21, twice for each). ExtendDB deleted such a table. A new table stays CREATING until the backend's first status pass after control_plane_delay_seconds (0.25 seconds by default). At the default, that took 0.65 to 1.22 seconds on SQLite, PostgreSQL and Cassandra. The DeleteTable handler now reads the table's description before the backend's delete, and it refuses a CREATING table with the service's text. The refusal therefore comes before the deletion protection check, as on the service. A CREATING table with a restore summary is a restore target, and the backend still refuses it as a table being restored. DynamoDB answers a restore target with another text, which #1316 tracks. When the describe fails, the backend's delete runs as before. On MongoDB and Cassandra, a restore that 0.1.14 or an earlier release did not finish left its target CREATING with no restore source. 1.0.0 deleted such a table, and DeleteTable now refuses it. The upgrade manual's v1.1.0 entry says to delete it before the upgrade. The new rows of tests/test_table_operations.py run on DynamoDB, and on PostgreSQL and SQLite with the table set CREATING in the catalog. test_target_and_backup_are_held_while_the_copy_runs now asserts the text of the refused DeleteTable of a restore target. The vector index refusal tests in tests/rust wait for ACTIVE before their DeleteTable. create_and_cleanup_table takes wait=False for a test that needs the table CREATING. The differences document has a row for the case. It and the usage guide gave 5 seconds as the default delay, which is 0.25 seconds. Closes #603 Refs #1316
LJMart11
left a comment
There was a problem hiding this comment.
Reviewed at 291052c.
1 finding is left inline.
| let probe = DescribeTableInput { | ||
| table_name: input.table_name.clone(), | ||
| }; | ||
| if let Ok(desc) = ctx.storage.describe_table(&ctx.account_id, probe).await |
There was a problem hiding this comment.
Update: Lee confirmed that no Cargo test pins the guard, but the existing Python integration tests fail under both mutants and pass at the head. The behavior is covered; no additional lower-level test is requested.
There was a problem hiding this comment.
Thanks LJMart11. You're right that no cargo test reads this check. At 2febb7b, which has main merged in, cargo test -p extenddb-engine passes with each of the two mutants, as it does without them (934 tests).
The PR's Python tests pin it instead. I built a SQLite server with each mutant and ran tests/test_table_operations.py and test_target_and_backup_are_held_while_the_copy_runs against it:
- With the
Creatingcondition made false, both rows oftest_delete_of_a_creating_table_is_refusedfail. DeleteTable deletes the plain table, and the protected one gets the deletion protection error. - With
restore_summary.is_none()made true,test_target_and_backup_are_held_while_the_copy_runsfails. The restore target getsTable is being created: <target>, and the test expectsTable is being restored: <target>.
On a server built from 2febb7b itself, all of these tests pass. So I left the tests as they are.
Main is at 5252eda. The base of this branch is main 8c64333, and main has 25 commits since then. Of the files that this branch changes, main changes four, and git reported a conflict in one of them. In docs/manuals/07-upgrade-manual.md, main and this branch each add a v1.1.0 entry at the same place. The merge keeps both entries, main's first.
jcshepherd
left a comment
There was a problem hiding this comment.
Approved pending green CI. Minor callouts all trigger merge conflicts or post-merge test failures, so I am assuming that mechanism will force them to be addressed on the later PR.
_deleting_catalog_backend() from main and _catalog_backend() from this branch read the backend under test from the server's config in the same way. _deleting_catalog_backend() now calls _catalog_backend() and then skips the test unless the backend is PostgreSQL or SQLite. The file now holds one copy of the lookup.
This branch refuses DeleteTable on a CREATING table, as DynamoDB does. test_the_backend_refuses_before_the_grammar_runs deleted the table at once when CreateTable accepted its vector index. The table was still CREATING, so the cleanup got ResourceInUseException, and the six wire jobs of the search inequality filters workflow failed. The test now calls wait_active from search_vectors_wire before it deletes the table.
|
@jcshepherd could you approve this again? Merging main dismissed your approval. Since your review, 5c53c63 merges main after #1411, and 53ddb3e gives the DELETING and CREATING tests one backend lookup. 5139144 makes a vector search test wait for ACTIVE before it deletes its table, because this PR refuses DeleteTable on a CREATING table. CI passed 69 of 69 at 5139144. |
Main fixed the default in the Table creation delay row of docs/differences-from-dynamodb.md (#1443), the same fix this branch made. The merge keeps main's row and adds this branch's row for DeleteTable on a CREATING table.
v1.1.0 shipped on 27 Nov 2026 without this change, so its upgrade note moves from the v1.1.0 entries to the top of the v1.2.0 entries. The note now names 1.1.0 as the release that deleted the table.
|
@jcshepherd I merged main again (c79beb4), because #1443 fixed the same |
Main added a v1.2.0 entry to the upgrade manual for #1093, at the place where this branch adds its entry. The merge keeps both, main's first.
|
@jcshepherd one more merge of main (1de5757). #1093 added its upgrade-manual entry at the place where this PR adds its own, and the merge keeps both. Nothing else changes, and the core and engine tests pass on the merge. |
Changes since the last review
delete_table.rs:30. No cargo test reads the check. The PR's Python tests pin it: each of the two mutants in that thread fails a test on a SQLite server built from it. Testing done gives the runs.What
DeleteTable now refuses a table that CreateTable is still creating, with DynamoDB's answer:
ResourceInUseExceptionandAttempt to change a resource which is still in use: Table is being created: <name>.handle_delete_tableincrates/engine/src/delete_table.rsreads the table's description before the backend's delete. ACREATINGtable without a restore summary gets the refusal, and nothing is deleted.CREATINGtable with a restore summary is a restore target. The backend still refuses it, as before, withTable is being restored: <name>. DynamoDB answers a restore target withTable: <name> is being used., and DeleteTable on a CREATING restore target answers "Table is being restored", where DynamoDB answers "Table: <name> is being used." #1316 tracks that text. fix(storage): answer DeleteTable on a restore target with DynamoDB's text #1366 changes the backends to DynamoDB's text for DeleteTable on a CREATING restore target answers "Table is being restored", where DynamoDB answers "Table: <name> is being used." #1316. The two PRs merge without a conflict, but with both merged,test_target_and_backup_are_held_while_the_copy_runsfails on ExtendDB until it expects DynamoDB's text there too.docs/differences-from-dynamodb.mdhas a row for DeleteTable on aCREATINGtable,docs/manuals/03-usage-guide.mdhas a sentence on it, anddocs/manuals/07-upgrade-manual.mdhas a v1.2.0 entry. The differences document and the usage guide gave 5 seconds as the defaultcontrol_plane_delay_seconds. They now give 0.25 seconds, as the admin guide and the four backends do.A new table stays
CREATINGuntil the backend's first status pass aftercontrol_plane_delay_seconds. SQLite, PostgreSQL and Cassandra make that pass every second, and MongoDB every 0.25 seconds. At the default of 0.25 seconds, a new table wasCREATINGfor 0.65 to 1.22 seconds in three measurements on each of SQLite, PostgreSQL and Cassandra. The check is in the engine, so it covers all four backends. The backends' own delete paths and their direct tests do not change.On MongoDB and Cassandra, a restore that 0.1.14 or an earlier release did not finish left its target
CREATINGwith no restore source. Main deletes such a table on DeleteTable. This change refuses it, because the engine cannot tell it from a table that CreateTable is creating.extenddb backup remove-targetrefuses it too, because no restore record names it. The upgrade entry says how to find such a table and to delete it before the upgrade. For one found after the upgrade, it says to roll back to 1.0.0 and delete it there. On SQLite and PostgreSQL, main already refuses such a table, as a table being restored. This change refuses it as a table being created.The refusal text starts with the service's prefix
Attempt to change a resource which is still in use:. Seven other literals incrates/carry the same prefix, and no constant holds it.Why
DynamoDB refuses DeleteTable on a
CREATINGtable, and ExtendDB deleted it. Measured in us-east-1 on 2026-11-21, twice for each row:ResourceInUseException,Attempt to change a resource which is still in use: Table is being created: <name>CREATINGCREATINGResourceInUseException,Attempt to change a resource which is still in use: Table: <name> is being used.CREATINGCloses #603
Testing done
At 2febb7b, which has main 5252eda merged in, unless a line names another commit.
test_delete_of_a_creating_table_is_refusedintests/test_table_operations.py, with the rows plain and protected:create_and_cleanup_tablecreates the table with its newwait=False, and DeleteTable follows at once. Both rows passed in each of two runs, at 291052c.CREATINGwith the transition an hour away, and sends DeleteTable. It asserts the status 400, the type and the text by equality, and the status from DescribeTable. Infinallyit sets the row back toACTIVEif the row still exists, and it turns deletion protection off.CREATINGthere.test_target_and_backup_are_held_while_the_copy_runsintests/test_backup_restore_fidelity.pynow asserts the text of the refused DeleteTable of aCREATINGrestore target: DynamoDB's text on the service, ExtendDB's text on ExtendDB. It passed on DynamoDB in one run withEXTENDDB_TEST_BACKUP_ITEMS=200, at 291052c, and on a SQLite server built from the branch.tests/rust/src/vector_index_unsupported.rs: six functions sent DeleteTable right after CreateTable and ignored the answer. With this change, each of them left its table in the server. Each now waits forACTIVEbefore its DeleteTable. At 291052c, the 7 tests of that file passed underdevtools/run-tests --extenddb --rust-integrationon a SQLite server built from the branch. They left no table in the catalog. The merge changes no file undertests/rust.tests/test_table_operations.py: 29 passed. On a server built from main, both new rows fail: the plain row's DeleteTable succeeds, and the protected row gets the deletion protection error.cargo +1.97.0 test -p extenddb-enginepasses with each of the two mutants below, as it does without them (934 tests).CREATINGcondition made false (the check disabled): both rows oftest_delete_of_a_creating_table_is_refusedrestore_summary.is_none()made true:test_target_and_backup_are_held_while_the_copy_runsACTIVErefused, at 291052c: the DELETING testcargo +1.97.0 fmt --all -- --check,cargo +1.97.0 test -p extenddb-engine --lib(933 passed),cargo +1.91.1 check -p extenddb-engine --all-targets,cargo +1.97.0 test -p extenddb-storage-postgres --test doc_version_literalsand both commands ofclippy.ymlforextenddb-engine: pass.The v1.2.0 entry in
docs/manuals/07-upgrade-manual.mdsits where other open PRs add their entries, so it can conflict with them.docs/getting-started.mdalso gives 5 seconds as the default. This change leaves it, because #491, #523, #530 and #537 rewrite that section. #523, #530 and #537 drop the paragraph, and #491 changes it to 0.25 seconds.#1411 by hitesh96db, for #602, changes the DELETING answer of
handle_delete_table. It conflicts with this branch incrates/engine/src/delete_table.rs, where both change theuseline, and intests/test_table_operations.py, where both add tests after the DELETING test._held_creatingintests/test_table_operations.pyrepeats the catalog steps of the DELETING test beside it. A shared helper for both tests would rewrite the DELETING test's lines that #550 changes. Whichever of #550 and this merges second can fold the two.Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
ADR / RFC: n/a
Breaking changes
A DeleteTable sent before DescribeTable reports the new table
ACTIVEnow fails withResourceInUseException, as on DynamoDB. Before, it deleted the table. A client that deletes tables right after it creates them waits forACTIVEfirst, or the deployment setscontrol_plane_delay_secondsto 0. On MongoDB and Cassandra, a table that an unfinished restore of 0.1.14 or an earlier release leftCREATINGcan no longer be deleted with DeleteTable. The upgrade manual has a v1.1.0 entry for these changes.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.