Skip to content

fix(engine): answer a restore from another region as DynamoDB does - #1359

Open
LeeroyHannigan wants to merge 9 commits into
fix/1354-backup-arn-accountfrom
fix/1326-cross-region-restore
Open

LeeroyHannigan wants to merge 9 commits into
fix/1354-backup-arn-accountfrom
fix/1326-cross-region-restore

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

The branch is at 6f959528e4. These commits sit on 0efe23cd5, the head that the review of 2 Dec 2026 read:

What

RestoreTableFromBackup now answers a BackupArn in another region as DynamoDB does. The BackupArn names the caller's account, and its region field is not the server's region. When the request has no SSESpecificationOverride, or has it as null, the answer is ValidationException with Invalid Request: sseSpecificationOverride must be provided for cross-region restores.

  • The cross-region text comes after the TargetTableName checks, the override value checks and the IndexName checks of the index overrides. It comes before the PROVISIONED rule, for every ARN shape. For an ARN with a bad id, partition or region field, it comes in place of that answer. For a well-formed ARN, it comes when the backup read finds no backup.
  • A table segment outside the pattern still gets Invalid Backup ARN first. So does a segment outside the length bounds of a table name, when no backup has that ARN.
  • With an SSESpecificationOverride of any content, {} included, the restore answers as for its own region. A region field or an id outside the shape gets Invalid Request: BackupArn is not valid. A backup that does not exist gets BackupNotFoundException.
  • The server restores a backup that it holds under another region's spelling, as before. A backup created under an earlier server.region is such a backup. DynamoDB's answer for an existing backup named with another region is not measured.
  • DescribeBackup and DeleteBackup keep their answers.

Before this change, the restore answered BackupNotFoundException for us-west-2 and Invalid Request: BackupArn is not valid for the other region fields, with or without an override.

cross_region_restore in crates/engine/src/backup.rs gives the answer at the two points of restore_table_from_backup that gave the old answers. One is the BackupArn check after the index names. The other is the point after the lookup where neither spelling of the ARN names a backup. It reads the override as the parse of the overrides reads it.

The restore also refuses a table segment outside the deployment's bounds for a table name, 3 to 255 by default. It does so when no backup has that ARN, and the answer is Invalid Backup ARN. Before, a segment of 2 or 300 characters got BackupNotFoundException. The check is in the restore, which has the limits, and names_a_stored_backup reads the backup as DescribeBackup does. So a backup taken before an operator raised min_table_name_length still restores. check_backup_arn takes no bounds, because a stored backup can name a table that a deployment with other limits created.

The PROVISIONED rule (validate_override_shape) now runs after the backup read. A restore of a backup that does not exist with BillingModeOverride PROVISIONED and no throughput gets BackupNotFoundException, as DynamoDB answers. That is one of the five rows of #1097.

docs/differences-from-dynamodb.md and docs/dynamodb-limits.md describe the cross-region text, its place and the bounds check.

The base of this PR is #1358.

Why

These are DynamoDB's answers, measured in us-east-1 on 21 and 22 November 2026 with signed requests. Each request went out twice and got the same answer both times. Each BackupArn names a backup of the caller's account that does not exist, in the partition aws unless the row gives another one. No restore started.

  • XREGION is ValidationException, Invalid Request: sseSpecificationOverride must be provided for cross-region restores.
  • NV is ValidationException, Invalid Request: BackupArn is not valid.
  • NOTFOUND is BackupNotFoundException, Backup not found: <the ARN as sent>.
  • IBA is ValidationException, Invalid Backup ARN.
Region field and other faults SSESpecificationOverride DynamoDB ExtendDB on #1358 ExtendDB with this PR
us-west-2 absent XREGION NOTFOUND XREGION
us/east-1, .., us-east-1/.. absent XREGION NV XREGION
US-EAST-1 absent XREGION NV XREGION
us-west-2, id bad absent XREGION NV XREGION
us/east-1, id bad absent XREGION NV XREGION
us-west-2, an id in upper-case hex absent XREGION NOTFOUND XREGION
cn-north-1 in the partition aws-cn absent XREGION NV XREGION
us/east-1 in the partition aws-cn absent XREGION NV XREGION
us-west-2 null XREGION NOTFOUND XREGION
us-west-2, table segment a b absent IBA IBA IBA
us-west-2 or us-east-1, table segment ab or of 300 t absent IBA NOTFOUND IBA
us-west-2, target name a* absent the length text of the name the same the same
us-west-2 {"Enabled": true}, {"Enabled": false}, {} or a KMS key NOTFOUND NOTFOUND NOTFOUND
us-west-2, an id in upper-case hex {"Enabled": true} NOTFOUND NOTFOUND NOTFOUND
us/east-1, US-EAST-1 {"Enabled": true} NV NV NV
us-west-2, id bad {"Enabled": true} NV NV NV

DescribeBackup answers NV for the region fields us/east-1, .., us-east-1/.. and US-EAST-1, and DeleteBackup answers NV for the first three. ExtendDB gives the same answers on both trees.

One more request got HTTP 500 InternalServerError from DynamoDB: a BackupArn in the partition aws-cn with an override. ExtendDB answers it with NV, as on #1358.

On 3 December 2026 these went out in the same way. INDEX is ValidationException with the length clause of the IndexName a at globalSecondaryIndexOverride.1.member.indexName.

Request DynamoDB and this PR
us-west-2, BillingModeOverride PROVISIONED, no throughput, the service's id or the id bad XREGION
us-east-1, BillingModeOverride PROVISIONED, no throughput NOTFOUND
us-west-2, {"Enabled": true}, BillingModeOverride PROVISIONED NOTFOUND
a GSI override with the IndexName a: us-west-2, us-west-2 with the id bad, us/east-1, and us-east-1 with the id bad INDEX
table segment of 255 t: us-west-2, then us-east-1 XREGION, then NOTFOUND
table segment of 256 t in us-west-2 IBA
us-west-2 with a trailing newline XREGION
us-east-1, table segment ab with a trailing newline IBA
us-east-1, table segment ab, with the target ab or with BillingModeOverride PAY IBA

Not measured: an empty region field. It gets the cross-region text without an override and NV with one. The probe requests got IAM denials from the session policy of the probe's credentials, so they do not show DynamoDB's answer.

Fixes #1326
Refs #1097

Testing done

At 6f959528e4, each cargo command with --locked:

  • cargo +1.97.0 test -p extenddb-core -p extenddb-engine -p extenddb-server --lib --no-fail-fast: core 1260 passed and 1 ignored, engine 984 passed, server 524 passed. On this host 5 backup_store::tests of the server fail on every branch, main included, because another user owns /local/home.
  • cargo +1.97.0 clippy of the core, engine, server and storage crates with --all-targets -- -D warnings, the same command with --features extenddb-engine/backup-test-hooks, cargo +1.94.0 check of the four crates with --all-targets, and cargo +1.97.0 fmt --all -- --check are clean.
  • cargo +1.97.0 test -p extenddb-wasm-adapter: the 3 unit tests pass, and the parity test passes all 281 cases of the corpus. The clippy step of the WebAssembly workflow is clean.
  • Against ExtendDB on SQLite built from this head: tests/test_backup_restore_fidelity.py 82 passed and tests/test_authz_cross_account.py 19 passed. pytest --collect-only -q collects tests/ and tests/python with no error.
  • Controls on 26239c18df, each with the tests kept: with every segment outside the bounds refused before the read, a_backup_of_a_name_outside_the_current_bounds_restores fails. With the cross-region call moved before the index name check, or the PROVISIONED rule moved before the read, a_restore_of_a_backup_arn_in_another_region_is_the_cross_region_answer fails.
  • On 0efe23cd5, against ExtendDB on SQLite (a release build), the 36 requests of the first table got the answers above.
  • An engine test restores a backup that the server stored under the region eu-west-1, an earlier server.region.

Line counts at 6f959528e4, against #1358's head 7de94a14a4: production +116 -30, tests +267 -28, docs +2 -2. The test files, the parity corpus and the lines after #[cfg(test)] and mod tests count as tests, and .md files as docs.

git merge-tree shows no conflict with main at c8e66fb568. This PR adds no conflict with any of the 106 open PRs that change the files of this stack. #1328 changes the same BackupArn texts and tests, and it conflicts with #1358 already, in the same files. Whichever of #1328 and this PR merges second has to keep cross_region_restore and the length check through the change that #1328 makes to check_backup_arn.

Not in this 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

Breaking changes

A restore of a BackupArn of another region, with no SSESpecificationOverride or a null one, gets the cross-region text, where it got BackupNotFoundException or Invalid Request: BackupArn is not valid. A restore of a BackupArn whose table segment is outside the deployment's table name bounds gets Invalid Backup ARN when no backup has that ARN, where it got BackupNotFoundException. A restore of a backup that does not exist with BillingModeOverride PROVISIONED and no throughput gets BackupNotFoundException, where it got the PROVISIONED text. A client that matches on the old texts sees the new ones. A restore of a stored backup gets the same answer as before. This holds for one named with another region and for one of a table name outside the current bounds. DescribeBackup and DeleteBackup get the same answers as before.


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 can name the caller's account and another region
in its BackupArn. When the request has no SSESpecificationOverride, or
has it as null, DynamoDB answers with ValidationException "Invalid
Request: sseSpecificationOverride must be provided for cross-region
restores".

DynamoDB gives that text after the TargetTableName checks and the
override values. It gives it before the id, partition and region shape
checks and before the backup read. So a region field with a slash, `..`
or upper-case letters gets it. An id it refuses, an upper-case hex id
and the aws-cn partition get it too. A table segment of 2 or 300
characters gets "Invalid Backup ARN" first, as one outside the pattern
does. That holds in another region and in the endpoint's own.

With an override of any content, {} included, the restore answers as for
its own region. A region field or an id outside the shape gets "Invalid
Request: BackupArn is not valid". A backup that does not exist gets
BackupNotFoundException. ExtendDB answered BackupNotFoundException for
another region and "Invalid Request: BackupArn is not valid" for the
other region fields, with or without an override. It answered
BackupNotFoundException for the table segments of 2 and 300 characters.

Measured in us-east-1 on 21 and 22 Nov 2026, each request twice. The
backups are backups of the caller's account that do not exist. The
partition is aws, and the id is the id of a backup unless the row gives
another one.

  BackupArn                     override         DynamoDB      before
  us-west-2                     none             cross-region  not found
  us/east-1, .., us-east-1/..   none             cross-region  not valid
  US-EAST-1                     none             cross-region  not valid
  us-west-2, id bad             none             cross-region  not valid
  us-west-2, upper-case hex id  none             cross-region  not found
  aws-cn cn-north-1             none             cross-region  not valid
  aws-cn us/east-1              none             cross-region  not valid
  us-west-2                     null             cross-region  not found
  us-west-2                     {"Enabled":true} not found     not found
  us-west-2                     {}               not found     not found
  us-west-2, upper-case hex id  {"Enabled":true} not found     not found
  us/east-1                     {"Enabled":true} not valid     not valid
  us-west-2, id bad             {"Enabled":true} not valid     not valid
  us-west-2, target name a*     none             length text   length text
  us-west-2, table ab           none             invalid ARN   not found
  us-west-2, table of 300 t     none             invalid ARN   not found
  us-east-1, table ab           none             invalid ARN   not found
  us-east-1, table of 300 t     none             invalid ARN   not found

The restore now gives the cross-region text, for no override or a null
one, in the two places that gave the old answers. One is the BackupArn
check after the target name. The other comes after the lookup, when
neither spelling of the ARN names a backup. The restore reads the
override as the parse of the overrides reads it. It also refuses a table
segment outside the deployment's table name bounds with "Invalid Backup
ARN". It does so before the target name, where it refuses one outside
the pattern.

The restore still finds and restores a backup that exists under another
region's spelling, such as a backup created under an earlier
server.region. DynamoDB's answer for an existing backup named with
another region is not measured.

DescribeBackup and DeleteBackup keep "Invalid Request: BackupArn is not
valid" for the region fields outside the shape, as DynamoDB answers
them.

Fixes #1326.
The new head of fix/1354-backup-arn-account holds main and the new
heads of fix/1272-invalid-backup-arn and fix/1271-restore-check-order.

Conflicts, all in backup.rs:

- backup_arn_member: this branch reads the BackupArn through
  backup_arn_text. fix/1272-invalid-backup-arn reads the fields of the
  ARN once, for the partition of an upper-case backup id. The merge
  keeps backup_arn_text and the fields.
- The doc of the restore steps, which the merge of
  fix/1271-restore-check-order rewrapped. The merge keeps the words and
  the line breaks of this branch.
- The comment of step 3 of the restore, where
  fix/1271-restore-check-order removed an issue number. The merge keeps
  the words of this branch without the number.
docs/differences-from-dynamodb.md listed a region outside [a-z0-9-] on
a restore as a difference from DynamoDB (#1326). This branch gives it
the cross-region text, as DynamoDB does, so the difference is gone. The
row now says that a restore refuses a table segment outside the
deployment's table name bounds. A backup of a table created before an
operator lowered max_table_name_length can be described and deleted,
but not restored, by its ARN.

The BackupArn row of docs/dynamodb-limits.md now names the bounds check
of a restore and the cross-region text. A restore with no
SSESpecificationOverride, or a null one, gets that text for an ARN
whose region field is not the server's region. It replaces the answers
after the TargetTableName and BackupNotFoundException.
The new head of fix/1354-backup-arn-account splits the long sentences
of the BackupArn account rows in docs/differences-from-dynamodb.md and
docs/dynamodb-limits.md. This branch changed the same rows, so both
files conflict. The merge keeps the changes of this branch and the
shorter sentences.
The bounds sentence of docs/differences-from-dynamodb.md and the
cross-region sentence of docs/dynamodb-limits.md had 38 and 36 words.
Each one is now two sentences of 25 words or fewer, with the same
facts.
@navareamol navareamol self-assigned this Dec 2, 2026

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

A stored backup whose table name is outside the current length limits can no longer be restored. I started a server with min_table_name_length = 1, created tables ab and a, backed both up, restarted with the default limits, and sent RestoreTableFromBackup with the ARN CreateBackup returned. #1358 restores both. This head answers "Invalid Backup ARN", while DescribeBackup and DeleteBackup still work. The description says check_backup_arn takes no bounds because a stored backup can name a table that a deployment with other limits created, and the comment in layout.rs says the same. The new check in restore_table_from_backup applies the bounds before any backup is read. I think the refusal for 2 and 300 characters should apply only when nothing resolves, next to the second cross_region_restore call. I have not tried that change. Would it keep your measured rows?

The cross-region text comes at different points for different ARNs. Take a request with no SSESpecificationOverride and a GlobalSecondaryIndexOverride whose IndexName is a, or BillingModeOverride PROVISIONED without ProvisionedThroughputOverride. With a well formed ARN in us-west-2 it answers the IndexName text or the "ProvisionedThroughputOverride must be specified" text. With us/east-1 in the region or the id bad it answers the cross-region text. The first case reaches cross_region_restore after parse_restore_table_overrides and check_index_names, the second before them. The description and the step 3 comment say the text comes before both. Did you send a bad IndexName with another region and no override to DynamoDB? No test pins the order: if I move the first call after parse_restore_table_overrides, all 469 engine backup tests still pass.

This head does not merge with main. A merge conflicts in crates/engine/src/backup.rs and crates/engine/src/lib.rs, in the same hunks as #1358. The cause is main moving canonical_backup_arn, check_backup_arn, create_backup_table_name and required_str into crates/engine/src/backup_requests.rs, so keeping both sides does not compile (duplicate definitions) and the lower commits need porting by hand. The history of this branch also holds #1353's head but not the current head of #1327, and #1353 shows as conflicting on GitHub. CI ran on 22 Nov on a tree from main of 18 Nov, so no WebAssembly run and none of the workflows added since has run on this code. Could you rebase the stack on current main and rerun CI?

For a backup that exists, a well formed other region restores without an override (HTTP 200 for us-west-2), and US-EAST-1 or us/east-1 gets the cross-region text. For a backup that does not exist every spelling gets the cross-region text, so the two answers tell a caller whether the backup exists, in their own account only. The description discloses that DynamoDB's answer for an existing backup is not measured. Your rows show DynamoDB answering the cross-region text for a backup that does not exist and NOTFOUND once an override is present, so I think the service checks the override before the lookup. Has an existing backup been sent with another region and no override?

Four edges are not pinned by a test: a 255 character table segment (changing min..=max to min..max keeps every engine test green), a 256 character one (max + 1), a padded ARN in the cross-region check, and a padded ARN in the length check. On the server they behave correctly today: 255 passes, 256 gives "Invalid Backup ARN", a padded ARN in us-west-2 gives the cross-region text. A wire row each would keep them.

docs/differences-from-dynamodb.md (the BackupArn row) and docs/dynamodb-limits.md still say a slash or .. in the region is "Invalid Request: BackupArn is not valid" and that another region of the caller's account resolves. A restore of those ARNs without an override now answers the cross-region text, and a table segment outside the bounds answers "Invalid Backup ARN".

I will approve once a stored backup with an earlier table name restores again, the order of the cross-region text is the same for every ARN shape or measured, the stack is rebased on current main with CI green on that tree, and the two docs rows describe the new answers.

The new head of fix/1354-backup-arn-account holds the new heads of
fix/1271-restore-check-order and fix/1272-invalid-backup-arn, and main
of 2 Dec.

Conflicts:

- backup.rs: check_backup_arn_account. This branch read the member
  through backup_arn_text, which trims it. fix/1354-backup-arn-account
  now reads the account from the member as sent. The merge keeps that
  read, and the doc of backup_arn_text names the account check as the
  one check that does not trim.
- docs/differences-from-dynamodb.md and docs/dynamodb-limits.md: the
  BackupArn rows. The merge keeps the rows of this branch and adds the
  sentences of fix/1354-backup-arn-account on the account check.
The restore refused a BackupArn whose table segment is outside the
deployment's table name bounds before it read any backup. A backup taken
before min_table_name_length went up could no longer be restored, though
DescribeBackup and DeleteBackup still read it. Main restores it.

The restore now looks a backup up first, as DescribeBackup does, when
the segment is outside the bounds. When it finds none, the answer is
still "Invalid Backup ARN" before the TargetTableName, the override
values and the cross-region text. DynamoDB gave that order on 3 Dec
2026. The requests had a segment of 2 characters, and a target name of
"ab" or a BillingModeOverride of "PAY".

The cross-region text also came at two points. For a BackupArn with a
bad id or region field it came before the override IndexName checks and
the PROVISIONED rule. For a well-formed one it came after both. DynamoDB
answers the IndexName clause first and the cross-region text before the
PROVISIONED rule, for every ARN shape. It checks the PROVISIONED rule
after it reads the backup, so a backup that does not exist is
BackupNotFoundException. DynamoDB gave these answers on 3 Dec 2026.
The restore now checks the override index names before the rest of the
BackupArn, and the PROVISIONED rule after the read.

The engine table of the cross-region restore gets 17 rows, and
_BACKUP_ARN_REGION_ROWS gets 12. A new engine test restores a stored
backup of the table "ab".
The BackupArn rows said that a restore refuses every table segment
outside the deployment's name bounds. So a stored backup of such a name
could not be restored. The restore now refuses the segment only when no
backup has that ARN, and the rows say so. The limits row also gives the
place of the cross-region text: after the clauses of the override index
names and before the PROVISIONED rule.
The new head of fix/1354-backup-arn-account gives the service's answer
for a padded backup ARN of another account in the BackupArn row of
docs/differences-from-dynamodb.md. The row named an issue number there.

Conflict:

- docs/differences-from-dynamodb.md: the BackupArn row. The merge keeps
  the row of this branch with that one sentence changed.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@navareamol

  1. 26239c18df restores such a backup again. When the table segment is outside the bounds, the restore reads the backup first, as DescribeBackup does. It refuses the segment only when no backup has that ARN. A refusal next to the second cross_region_restore call would not keep the measured rows. On 3 Dec 2026 DynamoDB answered Invalid Backup ARN to a segment of 2 characters. That answer came before a TargetTableName of ab and before a BillingModeOverride of PAY. So the refusal stays at step 2, before the target name and the override values, for an ARN that names no backup. The new engine test a_backup_of_a_name_outside_the_current_bounds_restores restores a stored backup of the table ab under the default bounds. An ab ARN that names no backup still gets Invalid Backup ARN there, before a target name of ab. With the old check put back, the test fails.
  2. I measured the order on 3 Dec 2026, each request twice. A GSI override entry with the IndexName a gets its length clause before the cross-region text for every ARN shape. The shapes were a well-formed ARN in us-west-2, the id bad in us-west-2, the region us/east-1, and the id bad in the caller's region. BillingModeOverride PROVISIONED without a throughput gets the cross-region text in us-west-2, with a good or a bad id. In the caller's region it gets BackupNotFoundException, so DynamoDB checks the PROVISIONED rule after it reads the backup. 26239c18df checks the override index names before the rest of the BackupArn checks, and the PROVISIONED rule after the read. The engine table of the cross-region restore gets 17 rows, and _BACKUP_ARN_REGION_ROWS gets 12. With the cross-region call moved before the index name check, or the PROVISIONED rule moved before the read, the engine test fails.
  3. The branch takes the new heads of fix(server): answer the account of a BackupArn before its shape #1358 with merges: ead864554f (at 6c53ce3774) and 6f959528e4 (at 7de94a14a4). Those hold fix(engine): answer a missing or malformed BackupArn as DynamoDB does #1327's pushed head and main of 2 Dec. At 6f959528e4, canonical_backup_arn, check_backup_arn, create_backup_table_name and required_str have one definition each, in crates/engine/src/backup_requests.rs, as on main. git merge-tree of 6f959528e4 with main at c8e66fb568 shows no conflict. CI runs when the branch is pushed.
  4. No. That request needs a backup in another region, and these measurements name only tables and backups that do not exist. With an SSESpecificationOverride, a missing backup in us-west-2 is BackupNotFoundException (3 Dec 2026). The lookup under the ARN as written is ExtendDB's choice: a backup taken under an earlier server.region stays reachable by the ARN that ListBackups reports for it. The two answers differ only for backups of the caller's own account, so the order stays.
  5. 26239c18df adds the four edges, measured on 3 Dec 2026. A segment of 255 characters gets the cross-region text in us-west-2 and BackupNotFoundException in the caller's region. A segment of 256 characters gets Invalid Backup ARN. A trailing newline gets the cross-region text on an ARN in us-west-2, and Invalid Backup ARN on a segment ab. The bounds rows are in the engine table and in _BACKUP_ARN_REGION_ROWS, and the two newline rows are in the engine table.
  6. bc4e812bfc changes both rows. A restore refuses a segment outside the bounds only when no backup has that ARN. Without an SSESpecificationOverride, an ARN whose region field is not the server's region gets the cross-region text, unless a stored backup has that ARN. The text comes after the clauses of the override index names and before the PROVISIONED rule.

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