Repository navigation
fix(engine): answer a restore from another region as DynamoDB does - #1359
LeeroyHannigan wants to merge 9 commits into
Conversation
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
left a comment
There was a problem hiding this comment.
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.
|
Changes since the last review
The branch is at
6f959528e4. These commits sit on0efe23cd5, the head that the review of 2 Dec 2026 read:9601f2413and06dc4c331merge fix(server): answer the account of a BackupArn before its shape #1358 at31f083682and3668aaa3d, which holdmainof 25 Nov and the heads of fix(engine): answer a missing or malformed BackupArn as DynamoDB does #1327 and fix(engine): check a restore's override values in DynamoDB's order #1353 of that day. Incrates/engine/src/backup.rs, the conflicts were inbackup_arn_member, in the doc of the restore steps and in the comment of step 3. TheBackupArnrows of the two docs files conflicted too. The merges keep the words of this PR and the changes of fix(server): answer the account of a BackupArn before its shape #1358.c15ba3632and697a46709:docs/differences-from-dynamodb.mdno longer lists the restore's answer to a region outside[a-z0-9-]as a difference. TheBackupArnrow ofdocs/dynamodb-limits.mdnames the bounds check and the cross-region text.ead864554fmerges fix(server): answer the account of a BackupArn before its shape #1358 at6c53ce3774, which holds fix(engine): answer a missing or malformed BackupArn as DynamoDB does #1327's pushed head andmainof 2 Dec. fix(server): answer the account of a BackupArn before its shape #1358 reads the account of aBackupArnas sent now. The merge keeps that read, and the doc ofbackup_arn_textnames the account check as the one check that does not trim. TheBackupArnrows of the two docs files keep the rows of this PR with the sentences of fix(server): answer the account of a BackupArn before its shape #1358 on the account check.26239c18dffixes the two faults that the review found. The restore refused a table segment outside the bounds before it read any backup. So a stored backup of such a table could not be restored. It now reads the backup first in that case, and refuses the segment only when no backup has that ARN. The cross-region text also came at two points for different ARN shapes. The restore now checks the override index names before the rest of theBackupArn, and the PROVISIONED rule after the backup read. DynamoDB uses that order for every ARN shape (measured on 3 December 2026). The engine table of the cross-region restore gets 17 rows and_BACKUP_ARN_REGION_ROWSgets 12. A new engine test restores a stored backup of the tableab.bc4e812bfc: theBackupArnrows of the two docs files give the bounds rule for a backup that does not exist and the place of the cross-region text.6f959528e4merges fix(server): answer the account of a BackupArn before its shape #1358 at7de94a14a4. One conflict, theBackupArnrow ofdocs/differences-from-dynamodb.md, where the merge keeps the row of this PR with the one sentence of fix(server): answer the account of a BackupArn before its shape #1358 changed.What
RestoreTableFromBackup now answers a
BackupArnin another region as DynamoDB does. TheBackupArnnames the caller's account, and its region field is not the server's region. When the request has noSSESpecificationOverride, or has it asnull, the answer isValidationExceptionwithInvalid Request: sseSpecificationOverride must be provided for cross-region restores.TargetTableNamechecks, the override value checks and theIndexNamechecks 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.Invalid Backup ARNfirst. So does a segment outside the length bounds of a table name, when no backup has that ARN.SSESpecificationOverrideof any content,{}included, the restore answers as for its own region. A region field or an id outside the shape getsInvalid Request: BackupArn is not valid. A backup that does not exist getsBackupNotFoundException.server.regionis such a backup. DynamoDB's answer for an existing backup named with another region is not measured.Before this change, the restore answered
BackupNotFoundExceptionforus-west-2andInvalid Request: BackupArn is not validfor the other region fields, with or without an override.cross_region_restoreincrates/engine/src/backup.rsgives the answer at the two points ofrestore_table_from_backupthat gave the old answers. One is theBackupArncheck 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 gotBackupNotFoundException. The check is in the restore, which has the limits, andnames_a_stored_backupreads the backup as DescribeBackup does. So a backup taken before an operator raisedmin_table_name_lengthstill restores.check_backup_arntakes 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 withBillingModeOverridePROVISIONED and no throughput getsBackupNotFoundException, as DynamoDB answers. That is one of the five rows of #1097.docs/differences-from-dynamodb.mdanddocs/dynamodb-limits.mddescribe 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
BackupArnnames a backup of the caller's account that does not exist, in the partitionawsunless the row gives another one. No restore started.ValidationException,Invalid Request: sseSpecificationOverride must be provided for cross-region restores.ValidationException,Invalid Request: BackupArn is not valid.BackupNotFoundException,Backup not found: <the ARN as sent>.ValidationException,Invalid Backup ARN.SSESpecificationOverrideus-west-2us/east-1,..,us-east-1/..US-EAST-1us-west-2, idbadus/east-1, idbadus-west-2, an id in upper-case hexcn-north-1in the partitionaws-cnus/east-1in the partitionaws-cnus-west-2nullus-west-2, table segmenta bus-west-2orus-east-1, table segmentabor of 300tus-west-2, target namea*us-west-2{"Enabled": true},{"Enabled": false},{}or a KMS keyus-west-2, an id in upper-case hex{"Enabled": true}us/east-1,US-EAST-1{"Enabled": true}us-west-2, idbad{"Enabled": true}DescribeBackup answers NV for the region fields
us/east-1,..,us-east-1/..andUS-EAST-1, and DeleteBackup answers NV for the first three. ExtendDB gives the same answers on both trees.One more request got HTTP 500
InternalServerErrorfrom DynamoDB: aBackupArnin the partitionaws-cnwith an override. ExtendDB answers it with NV, as on #1358.On 3 December 2026 these went out in the same way. INDEX is
ValidationExceptionwith the length clause of theIndexNameaatglobalSecondaryIndexOverride.1.member.indexName.us-west-2,BillingModeOverridePROVISIONED, no throughput, the service's id or the idbadus-east-1,BillingModeOverridePROVISIONED, no throughputus-west-2,{"Enabled": true},BillingModeOverridePROVISIONEDIndexNamea:us-west-2,us-west-2with the idbad,us/east-1, andus-east-1with the idbadt:us-west-2, thenus-east-1tinus-west-2us-west-2with a trailing newlineus-east-1, table segmentabwith a trailing newlineus-east-1, table segmentab, with the targetabor withBillingModeOverridePAYNot 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 5backup_store::testsof the server fail on every branch,mainincluded, because another user owns/local/home.cargo +1.97.0 clippyof 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 checkof the four crates with--all-targets, andcargo +1.97.0 fmt --all -- --checkare 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.tests/test_backup_restore_fidelity.py82 passed andtests/test_authz_cross_account.py19 passed.pytest --collect-only -qcollectstests/andtests/pythonwith no error.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_restoresfails. 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_answerfails.0efe23cd5, against ExtendDB on SQLite (a release build), the 36 requests of the first table got the answers above.eu-west-1, an earlierserver.region.Line counts at
6f959528e4, against #1358's head7de94a14a4: production +116 -30, tests +267 -28, docs +2 -2. The test files, the parity corpus and the lines after#[cfg(test)]andmod testscount as tests, and.mdfiles as docs.git merge-treeshows no conflict withmainatc8e66fb568. This PR adds no conflict with any of the 106 open PRs that change the files of this stack. #1328 changes the sameBackupArntexts and tests, and it conflicts with #1358 already, in the same files. Whichever of #1328 and this PR merges second has to keepcross_region_restoreand the length check through the change that #1328 makes tocheck_backup_arn.Not in this PR:
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 restore of a
BackupArnof another region, with noSSESpecificationOverrideor a null one, gets the cross-region text, where it gotBackupNotFoundExceptionorInvalid Request: BackupArn is not valid. A restore of aBackupArnwhose table segment is outside the deployment's table name bounds getsInvalid Backup ARNwhen no backup has that ARN, where it gotBackupNotFoundException. A restore of a backup that does not exist withBillingModeOverridePROVISIONED and no throughput getsBackupNotFoundException, 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.