Skip to content

fix(engine): refuse DeleteTable on a table that is still CREATING - #1329

Open
LeeroyHannigan wants to merge 9 commits into
mainfrom
fix/603-delete-creating-table
Open

LeeroyHannigan wants to merge 9 commits into
mainfrom
fix/603-delete-creating-table

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

What

DeleteTable now refuses a table that CreateTable is still creating, with DynamoDB's answer: ResourceInUseException and Attempt to change a resource which is still in use: Table is being created: <name>.

A new table stays CREATING until the backend's first status pass after control_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 was CREATING for 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 CREATING with 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-target refuses 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 in crates/ carry the same prefix, and no constant holds it.

Why

DynamoDB refuses DeleteTable on a CREATING table, and ExtendDB deleted it. Measured in us-east-1 on 2026-11-21, twice for each row:

Table DeleteTable on DynamoDB DescribeTable after it
New table, CREATING 400 ResourceInUseException, Attempt to change a resource which is still in use: Table is being created: <name> CREATING
New table with deletion protection, CREATING the same CREATING
Restore target, CREATING 400 ResourceInUseException, Attempt to change a resource which is still in use: Table: <name> is being used. CREATING

Closes #603

Testing done

At 2febb7b, which has main 5252eda merged in, unless a line names another commit.

  • New test_delete_of_a_creating_table_is_refused in tests/test_table_operations.py, with the rows plain and protected:
    • On DynamoDB, create_and_cleanup_table creates the table with its new wait=False, and DeleteTable follows at once. Both rows passed in each of two runs, at 291052c.
    • On PostgreSQL and SQLite, the test creates the table, sets its catalog row CREATING with 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. In finally it sets the row back to ACTIVE if the row still exists, and it turns deletion protection off.
    • MongoDB and Cassandra are not covered by this test, because it cannot set a table CREATING there.
  • test_target_and_backup_are_held_while_the_copy_runs in tests/test_backup_restore_fidelity.py now asserts the text of the refused DeleteTable of a CREATING restore target: DynamoDB's text on the service, ExtendDB's text on ExtendDB. It passed on DynamoDB in one run with EXTENDDB_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 for ACTIVE before its DeleteTable. At 291052c, the 7 tests of that file passed under devtools/run-tests --extenddb --rust-integration on a SQLite server built from the branch. They left no table in the catalog. The merge changes no file under tests/rust.
  • On a SQLite server built from the branch, 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.
  • No cargo test reads the check. cargo +1.97.0 test -p extenddb-engine passes with each of the two mutants below, as it does without them (934 tests).
  • Mutants, each built into its own SQLite server, and a test fails for each:
    • the CREATING condition made false (the check disabled): both rows of test_delete_of_a_creating_table_is_refused
    • restore_summary.is_none() made true: test_target_and_backup_are_held_while_the_copy_runs
    • any status other than ACTIVE refused, at 291052c: the DELETING test
  • cargo +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_literals and both commands of clippy.yml for extenddb-engine: pass.

The v1.2.0 entry in docs/manuals/07-upgrade-manual.md sits where other open PRs add their entries, so it can conflict with them. docs/getting-started.md also 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 in crates/engine/src/delete_table.rs, where both change the use line, and in tests/test_table_operations.py, where both add tests after the DELETING test.

_held_creating in tests/test_table_operations.py repeats 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

  • 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

Breaking changes

A DeleteTable sent before DescribeTable reports the new table ACTIVE now fails with ResourceInUseException, as on DynamoDB. Before, it deleted the table. A client that deletes tables right after it creates them waits for ACTIVE first, or the deployment sets control_plane_delay_seconds to 0. On MongoDB and Cassandra, a table that an unfinished restore of 0.1.14 or an earlier release left CREATING can 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.

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

@LJMart11 LJMart11 Nov 25, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

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.

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 Creating condition made false, both rows of test_delete_of_a_creating_table_is_refused fail. 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_runs fails. The restore target gets Table is being created: <target>, and the test expects Table 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
jcshepherd previously approved these changes Nov 25, 2026

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

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

Copy link
Copy Markdown
Collaborator Author

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

Copy link
Copy Markdown
Collaborator Author

@jcshepherd I merged main again (c79beb4), because #1443 fixed the same control_plane_delay_seconds default in docs/differences-from-dynamodb.md that this PR fixed. The merge keeps main's row. So in that file the PR now adds only its DeleteTable row, and in the usage guide only its DeleteTable sentence. f7f9851 moves the upgrade note from v1.1.0 to v1.2.0, because v1.1.0 shipped on 27 Nov without this change. The core and engine tests pass on the merge. Could you approve this head?

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

Copy link
Copy Markdown
Collaborator Author

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

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

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DeleteTable on a table that is still CREATING is served; DynamoDB refuses it

3 participants