Skip to content

fix(engine): give a restore into another backup's target DynamoDB's text - #1371

Open
LeeroyHannigan wants to merge 1 commit into
fix/1316-delete-restore-targetfrom
fix/1369-restore-other-backup
Open

LeeroyHannigan wants to merge 1 commit into
fix/1316-delete-restore-targetfrom
fix/1369-restore-other-backup

Conversation

@LeeroyHannigan

Copy link
Copy Markdown
Collaborator

What

A RestoreTableFromBackup can name a target that is still CREATING from a restore of another backup. Such a request now gets TableInUseException with the text that DynamoDB gives:

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

Before, the answer was the text for the same backup, Table: <name> is already being restored from backup: <arn>, and the ARN was the backup of the restore in progress. A restore that names the backup of the restore in progress keeps that text.

The changes:

  • restore_storage_err_to_dynamo in crates/engine/src/backup.rs now takes the ARN that the request resolved to. A StorageError::TableBeingRestored carries the backup of the restore in progress, which is the target's RestoreSummary.SourceBackupArn. When the two ARNs differ, the answer is the new text.
  • restore_target_in_use_message in crates/storage/src/backup_catalog.rs gives the text. It is split out of restore_target_in_use, which fix(storage): answer DeleteTable on a restore target with DynamoDB's text #1366 adds for DeleteTable. So DeleteTable and the restore share one copy of the text.
  • Each call site passes the resolved ARN. On the path without a backup store, these are check_restore_target_name and the backend's registration. On the store-backed path, they are the name check, the registration in flight and the claim refusal.
  • One sentence of the row "Restoring into a name that exists" in docs/differences-from-dynamodb.md changes. It said that ExtendDB does not give the text for another backup.

The base of this PR is #1366.

Fixes #1369

Why

These are DynamoDB's answers, measured in us-east-1 on 22 November 2026. A table with one item had two backups, B1 and B2, both AVAILABLE. A RestoreTableFromBackup of B1 into a new name made the target. DescribeTable of the target gave TableStatus CREATING, with B1 as RestoreSummary.SourceBackupArn. Each request below went out twice, 5 seconds apart, and got the same answer both times.

Request into the name of the target DynamoDB ExtendDB before ExtendDB with this PR
RestoreTableFromBackup of B2 400 TableInUseException, Attempt to change a resource which is still in use: Table: <name> is being used. 400 TableInUseException, Table: <name> is already being restored from backup: <B1 ARN> the same as DynamoDB
RestoreTableFromBackup of B1 400 TableInUseException, Table: <name> is already being restored from backup: <B1 ARN> the same as DynamoDB the same as DynamoDB

Testing done

  • cargo test -p extenddb-engine --lib backup --no-fail-fast: 467 passed. cargo test -p extenddb-storage --no-fail-fast: 284 passed.
  • cargo +1.97.0 clippy -p extenddb-engine -p extenddb-storage --all-targets -- -D warnings and cargo +1.97.0 fmt --all -- --check are clean.
  • The new rows are in five existing engine tests, with no new test function. They cover the three call sites of the store-backed path with an in-memory store. Three rows expect the same-backup text for B1 written with surrounding whitespace, in another region, or under an earlier server.region. DynamoDB was not measured with these spellings of the ARN.
  • A control reverts the change in the engine and keeps the tests. Then 5 tests fail on their rows for another backup.
  • Against a release build on SQLite with no backup store, the two requests of the table got DynamoDB's answers, twice each. B1 with whitespace and B1 written in eu-west-1 got the text for the same backup, with the stored ARN. The target then became ACTIVE with all 60,000 items. tests/test_backup_restore_fidelity.py passed 37 tests with EXTENDDB_TEST_BACKUP_STORE=none.
  • The store-backed path did not run against a server on this host. A filesystem store refuses its parent directories here, because uid 65534 owns /, /local and /local/home, and no S3 endpoint was running.
  • The last amend changed one doc comment, inlined one test variable and made one test check the text. The server runs above used the commit before it. The engine tests ran on the last commit.
  • The commit merged with the head of fix(engine): refuse a BackupArn table segment of a bad length #1367, the top of the open backup stack, passed the engine backup tests (468).

Production is +58 -29 and the tests are +87 -44.

git merge-tree shows no conflict with main, #1359, #1365, #1366, #1367 or #1096. This PR adds no conflict with any open PR.

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.

A RestoreTableFromBackup into a CREATING restore target answered the
text for the backup of the restore in progress, whichever backup it
named. That text is "Table: <name> is already being restored from
backup: <arn>". All four backends answered it.

Measured on DynamoDB in us-east-1 on 22 Nov 2026, with a target CREATING
from backup B1. Each request went out twice, 5 seconds apart, and got
the same 400 both times:

- B2 into the target's name: TableInUseException, "Attempt to change a
  resource which is still in use: Table: <name> is being used."
- B1 into the target's name: TableInUseException, "Table: <name> is
  already being restored from backup: <B1 ARN>".

restore_storage_err_to_dynamo now takes the ARN the request resolved to.
It compares that ARN with the backup a TableBeingRestored error carries,
the target's RestoreSummary.SourceBackupArn. The same backup keeps its
text. Another backup gets the measured text from
restore_target_in_use_message. That function is split out of
restore_target_in_use, so DeleteTable and the restore share one copy of
the text.

Each call site passes the resolved ARN. The legacy path passes the
spelling the legacy reader resolved, and the catalog row path passes the
row's ARN. The same backup keeps its text in each spelling the engine
resolves: trimmed, another region, or an earlier server.region.

The row "Restoring into a name that exists" of
docs/differences-from-dynamodb.md now records the different-backup text.

Fixes #1369.

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

I think the new answer has no test on a backend. The five changed engine tests use a fake backend and a store held in memory, and the engine picks the text by comparing the ARN the request resolved to with the backup_arn that the backend reads from the target's restore row. So the text depends on each backend storing the same spelling. The docs row now states the other backup text for all four backends, and test_restore_into_a_creating_target_and_a_second_restore_of_its_backup_are_refused in tests/test_backup_restore_fidelity.py only restores the same backup. On SQLite, with and without a backup store, I restored a second backup of the same table into the CREATING target and got "Attempt to change a resource which is still in use: Table: is being used.", and the base gave the first backup's text. Could you add a second backup to that wire test and check this text, so CI runs it on PostgreSQL, Cassandra and MongoDB too?

The description says there is no conflict with main or #1096. On current main (92155f3) it conflicts in crates/engine/src/backup.rs, on the use extenddb_storage::backup_catalog line: main removed TimeBounds and this PR adds restore_target_in_use_message. #1366 alone merges clean, and #1096 now conflicts on the same line for the same reason. With both sides kept, the engine lib tests pass (978) and the SQLite run gives the same answers. The CI here ran before main added its wasm and other workflows, so none of them has run on this code. Could you merge main and update the sentence?

Three of the new engine rows expect the same backup text for the backup's ARN with surrounding whitespace, written with another region, and stored under an earlier server.region. The description says DynamoDB was not measured with these. Has anyone sent the padded ARN or the other region ARN of the same backup into its CREATING target on DynamoDB?

I will approve once a wire test checks the other backup text on every backend and main is merged with CI green on it.

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.

2 participants