Skip to content

fix(storage): answer DeleteTable on a restore target with DynamoDB's text - #1366

Open
LeeroyHannigan wants to merge 1 commit into
mainfrom
fix/1316-delete-restore-target
Open

LeeroyHannigan wants to merge 1 commit into
mainfrom
fix/1316-delete-restore-target

Conversation

@LeeroyHannigan

Copy link
Copy Markdown
Collaborator

What

DeleteTable on a restore target that is still CREATING now answers DynamoDB's text on SQLite, PostgreSQL, MongoDB and Cassandra: ResourceInUseException with Attempt to change a resource which is still in use: Table: <name> is being used. Before, each backend answered Attempt to change a resource which is still in use: Table is being restored: <name>.

The text comes from one function, restore_target_in_use in crates/storage/src/backup_catalog.rs, next to backup_in_use. The four delete paths call it, and the Cassandra backend's own table_being_restored helper is gone. The exception type and every other answer of the delete paths do not change.

DeleteTable on a table that CreateTable is still creating is a separate case (#603). This PR does not change it.

Fixes #1316

Why

This is DynamoDB's answer, measured in us-east-1 on 21 November 2026. A RestoreTableFromBackup of an AVAILABLE backup made a new target. DescribeTable of the target gave TableStatus CREATING and RestoreSummary.RestoreInProgress true. DeleteTable of the target went out twice, 5 seconds apart, and both times got HTTP 400 ResourceInUseException with Attempt to change a resource which is still in use: Table: <name> is being used.

Testing done

  • cargo test -p extenddb-storage -p extenddb-storage-sqlite --no-fail-fast: 286 storage tests and 316 SQLite tests passed. 4 SQLite tests of the filesystem backup store fail on this host on main too, because uid 65534 owns every ancestor directory.
  • cargo test --lib passed 84 PostgreSQL, 190 MongoDB and 178 Cassandra tests. Three tests need a database container and did not run on this host. They are the PostgreSQL test in tests/backup_restore.rs, the Cassandra held-target test and the MongoDB live test.
  • cargo +1.97.0 clippy on the five storage crates with --all-targets -- -D warnings, and cargo +1.97.0 fmt --all -- --check, are clean.
  • A control reverts the production change and keeps the tests. Then the SQLite test fails with the old text.
  • Against a release build on SQLite, two DeleteTables on a CREATING restore target got DynamoDB's answer, and the restore still copied all 60,000 items. The same target answers HTTP 200 once it is ACTIVE. A table that CreateTable is still creating answers as on main. tests/test_backup_restore_fidelity.py passed 37 tests.
  • The last amend shortened a doc comment. The runs above used the commit before it.

Production is +17 -23 and the tests are +15 -4.

#1329 expects the old text in tests/test_backup_restore_fidelity.py and in its new row of docs/differences-from-dynamodb.md. The two PRs merge without a conflict, but with both merged, test_target_and_backup_are_held_while_the_copy_runs fails on ExtendDB. Whichever of the two merges second expects Table: <target> is being used. on DynamoDB and ExtendDB alike, and drops the sentence of the row about the text of the backend.

git merge-tree shows no conflict with main. In crates/storage-cassandra/src/delete_table.rs, this PR adds one conflict hunk with #599 and one with #550, and two with #598, which conflicts there already. The resolution keeps their status == "CREATING" condition and the call to restore_target_in_use. None of them adds a call to table_being_restored, which this PR deletes.

Not in this PR: a RestoreTableFromBackup into a CREATING target of another backup. ExtendDB answers it with the text for the same backup, where DynamoDB answers Table: <name> is being used. The row "Restoring into a name that exists" of docs/differences-from-dynamodb.md records it.

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


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.

…text

DeleteTable on a restore target that is still CREATING answered
ResourceInUseException on all four backends. Its text was "Attempt to
change a resource which is still in use: Table is being restored:
<name>". DynamoDB answers the same exception with another text.
Measured in us-east-1 on 2026-11-21, twice, 5 seconds apart, on a target
whose DescribeTable gave TableStatus CREATING and
RestoreSummary.RestoreInProgress true:

  400 ResourceInUseException
  Attempt to change a resource which is still in use: Table: <name> is
  being used.

The text now comes from one function, restore_target_in_use in
extenddb_storage::backup_catalog, next to backup_in_use. The SQLite,
PostgreSQL, MongoDB and Cassandra delete paths call it, and the
Cassandra backend's own table_being_restored helper is gone. The
exception type and every other answer of the delete paths are unchanged.

The text for a table that CreateTable is still creating is a separate
case (#603) and does not change here.

The four backend tests that cover DeleteTable of a CREATING restore
target now assert the measured text by equality.

Fixes #1316.

@hitesh96db hitesh96db left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The change is a text-only substitution at the four refusal sites, and which tables get refused is the same as on main. On a SQLite build of this head, and on a merge into current main, DeleteTable on a restore target that is still CREATING now answers ResourceInUseException with Attempt to change a resource which is still in use: Table: <name> is being used., the text recorded in #1316. DeleteTable on a table that does not exist, an ACTIVE table, a DELETING table, a table CreateTable is still creating, and a restore source answer as they do on main. CI is green (58 of 58).

Suggestions, none blocking:

  • test_target_and_backup_are_held_while_the_copy_runs (tests/test_backup_restore_fidelity.py, lines 1258 to 1316) checks only the exception class (line 1281). Asserting the message there would pin the text on all four backends in CI. The exact-text tests for PostgreSQL, MongoDB and Cassandra need a server or cluster, and the PR body says they did not run for you, so today CI proves the text on SQLite only.
  • docs/differences-from-dynamodb.md line 130 ("DeleteBackup and DeleteTable during a restore") gives the exception without the text in either column. #1316 names that row, and the "documentation updated" box is unticked.
  • A question about the measurement. On DynamoDB a restore target answers differently at two points while it is CREATING. In two restores I ran on 2026-11-30, for about 5 to 31 seconds after the restore started, every operation answered as if the table did not exist (for example UpdateTable: ResourceNotFoundException, Requested resource not found: Table: <name> not found). After that, UpdateTable and TagResource answered ResourceInUseException with Attempt to change a resource which is still in use: Table is being used: <name>, and DescribeTable read CREATING with RestoreInProgress true the whole time. I could not run DeleteTable on DynamoDB, so I do not know which of the two stages your 2026-11-21 measurement in #1316 sampled. A DeleteTable at both stages would show whether the early one needs its own answer.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DeleteTable on a CREATING restore target answers "Table is being restored", where DynamoDB answers "Table: <name> is being used."

2 participants