From c8dbf48d202d901a9849a7d91aaea494a578649e Mon Sep 17 00:00:00 2001 From: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com> Date: Sun, 22 Nov 2026 22:34:55 +0000 Subject: [PATCH] fix(engine): give a restore into another backup's target DynamoDB's text 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: is already being restored from backup: ". 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: is being used." - B1 into the target's name: TableInUseException, "Table: is already being restored from backup: ". 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. --- crates/engine/src/backup.rs | 66 +++++++++----- crates/engine/src/backup/restore.rs | 3 +- crates/engine/src/backup/tests.rs | 131 ++++++++++++++++++--------- crates/storage/src/backup_catalog.rs | 16 +++- docs/differences-from-dynamodb.md | 2 +- 5 files changed, 145 insertions(+), 73 deletions(-) diff --git a/crates/engine/src/backup.rs b/crates/engine/src/backup.rs index 80e9254e9..56e2cb1ba 100755 --- a/crates/engine/src/backup.rs +++ b/crates/engine/src/backup.rs @@ -26,6 +26,7 @@ use extenddb_core::types::{ }; use extenddb_storage::backup_catalog::{ BackupKey, BackupRow, BackupStatus, DeleteStart, TimeBounds, is_backup_not_found, + restore_target_in_use_message, }; use extenddb_storage::error::StorageError; use extenddb_storage::{ @@ -1845,7 +1846,7 @@ where // 5. The target name, after the backup resolved and before the overrides // are checked against it. - check_restore_target_name(storage, account_id, target_table_name).await?; + check_restore_target_name(storage, account_id, target_table_name, &backup_arn).await?; // 6. Refusals every backend gets, whatever it stores. source.ensure_restorable().map_err(storage_err_to_dynamo)?; @@ -1883,7 +1884,7 @@ where .await .map_err(storage_err_to_dynamo)? else { - return Err(restore_storage_err_to_dynamo(e)); + return Err(restore_storage_err_to_dynamo(e, &backup_arn)); }; return restore_from_row( storage_arc, @@ -1899,7 +1900,7 @@ where .await; } // 10. - Err(e) => return Err(restore_storage_err_to_dynamo(e)), + Err(e) => return Err(restore_storage_err_to_dynamo(e, &backup_arn)), }; let response = restore_response(desc, &RestoreSource::from(&source), on_demand)?; @@ -1937,7 +1938,13 @@ where // backup into an existing table is TableAlreadyExistsException, a // backup into its own CREATING target TableInUseException, not // BackupInUseException) and before the manifest is read. - check_restore_target_name(&**storage, account_id, target_table_name).await?; + check_restore_target_name( + &**storage, + account_id, + target_table_name, + &arn.to_arn_string(), + ) + .await?; let store = check_catalog_row_for_restore(&**storage, runtime, arn, row).await?; restore::request( storage, @@ -1998,12 +2005,11 @@ async fn check_catalog_row_for_restore<'r, S: BackupCatalog + ?Sized>( runtime.require_healthy_store() } -/// Step 5 of a restore, the target name under the account, read through -/// `describe_table` after the backup resolved and before the permit: a -/// CREATING table with a -/// `RestoreSummary` is a restore target, `TableInUseException` naming its -/// source backup (the text the backend's own registration answers with, -/// [`StorageError::TableBeingRestored`]); any other table of that name is +/// Step 5 of a restore of `backup_arn`, the target name under the account, +/// read through `describe_table` after the backup resolved and before the +/// permit: a CREATING table with a `RestoreSummary` is a restore target, +/// answered as the backend's registration answers it +/// ([`restore_storage_err_to_dynamo`]); any other table of that name is /// `TableAlreadyExistsException`; no table passes. Unfenced: the backend /// checks the name again under its registration, so two restores into one /// free name still have one winner. @@ -2011,6 +2017,7 @@ async fn check_restore_target_name( storage: &S, account_id: &str, target_table_name: &str, + backup_arn: &str, ) -> Result<(), DynamoDbError> { let probe = storage .describe_table( @@ -2027,13 +2034,16 @@ async fn check_restore_target_name( .as_ref() .filter(|_| desc.table_status == TableStatus::Creating) .and_then(|s| s.source_backup_arn.clone()); - Err(restore_storage_err_to_dynamo(match source { - Some(backup_arn) => StorageError::TableBeingRestored { - table_name: target_table_name.to_owned(), - backup_arn, + Err(restore_storage_err_to_dynamo( + match source { + Some(backup_arn) => StorageError::TableBeingRestored { + table_name: target_table_name.to_owned(), + backup_arn, + }, + None => StorageError::TableAlreadyExists(target_table_name.to_owned()), }, - None => StorageError::TableAlreadyExists(target_table_name.to_owned()), - })) + backup_arn, + )) } Err(StorageError::TableNotFound(_)) => Ok(()), Err(e) => Err(storage_err_to_dynamo(e)), @@ -2113,20 +2123,30 @@ fn restore_response( Ok(out) } -/// [`storage_err_to_dynamo`] for RestoreTableFromBackup, where a taken target -/// name is `TableAlreadyExistsException` (the operation's own error in the -/// service model, and what the service returns), and a name taken by a -/// `CREATING` restore target is `TableInUseException` with the service's text -/// (`Table: is already being restored from backup: `, measured on -/// DynamoDB), which the storage error's `Display` carries. +/// [`storage_err_to_dynamo`] for a RestoreTableFromBackup of `backup_arn`, +/// where a taken target name is `TableAlreadyExistsException` (the +/// operation's own error in the service model, and what the service +/// returns), and a name taken by a `CREATING` restore target is +/// `TableInUseException` with the service's text (both measured on +/// DynamoDB): `Table: is already being restored from backup: `, +/// the storage error's `Display`, when that target is restored from +/// `backup_arn`, else [`restore_target_in_use_message`]. `backup_arn` is the +/// ARN the request resolved to, the spelling a target's `RestoreSummary` +/// holds, so the two compare as strings. /// A backup with a restore from it still `CREATING` is `BackupInUseException` /// (the generic mapping; measured on DynamoDB). Only this operation maps the /// first two so; CreateTable keeps `ResourceInUseException`. -fn restore_storage_err_to_dynamo(e: StorageError) -> DynamoDbError { +fn restore_storage_err_to_dynamo(e: StorageError, backup_arn: &str) -> DynamoDbError { match e { StorageError::TableAlreadyExists(name) => DynamoDbError::TableAlreadyExistsException( error_message(ErrorMessageKey::TableAlreadyExists, &[&name]), ), + StorageError::TableBeingRestored { + table_name, + backup_arn: restoring, + } if restoring != backup_arn => { + DynamoDbError::TableInUseException(restore_target_in_use_message(&table_name)) + } e @ StorageError::TableBeingRestored { .. } => { DynamoDbError::TableInUseException(e.to_string()) } diff --git a/crates/engine/src/backup/restore.rs b/crates/engine/src/backup/restore.rs index 31cfedd58..6525b229f 100644 --- a/crates/engine/src/backup/restore.rs +++ b/crates/engine/src/backup/restore.rs @@ -323,6 +323,7 @@ where table_name: target_table_name.to_owned(), backup_arn: in_flight.backup_arn, }, + &arn_text, )); } tracing::info!( @@ -485,7 +486,7 @@ pub(crate) async fn start( Ok(registered) => registered, Err(e) => { drop(permit); - let error = restore_storage_err_to_dynamo(e); + let error = restore_storage_err_to_dynamo(e, &arn_text); if let Some(registration) = registration { registration.finish(Err(error.clone())); } diff --git a/crates/engine/src/backup/tests.rs b/crates/engine/src/backup/tests.rs index 204be8e56..e8c823e7a 100644 --- a/crates/engine/src/backup/tests.rs +++ b/crates/engine/src/backup/tests.rs @@ -6205,31 +6205,50 @@ async fn a_taken_name_is_table_already_exists_on_restore_only() { /// Measured on DynamoDB: a target name taken by a /// `CREATING` restore is `TableInUseException` `Table: is already -/// being restored from backup: `; a backup with a restore from it still +/// being restored from backup: ` for that restore's backup and +/// `Attempt to change a resource which is still in use: Table: is +/// being used.` for another; a backup with a restore from it still /// `CREATING` is `BackupInUseException`. The backends raise the storage -/// errors; this is their mapping. +/// errors; this is their mapping, for the backup the request resolved to. #[tokio::test] async fn a_name_being_restored_is_table_in_use_and_a_backup_being_restored_is_backup_in_use() { - let fake = Fake::with_source(source(Some(definition("PROVISIONED")))); - *fake.restore_error.lock().unwrap() = Some(StorageError::TableBeingRestored { - table_name: "MusicRestored".to_owned(), - backup_arn: arn(ACCOUNT), - }); - let err = restore(&fake, restore_body(json!({}))).await.unwrap_err(); - match &err { - DynamoDbError::TableInUseException(m) => assert_eq!( - m, - &format!( - "Table: MusicRestored is already being restored from backup: {}", - arn(ACCOUNT) - ) - ), - other => panic!("expected TableInUseException, got {other:?}"), + let ours = arn(ACCOUNT); + let earlier = ours.replace(REGION, "eu-west-1"); + let b2 = arn_n(2); + let same = + |arn: &str| format!("Table: MusicRestored is already being restored from backup: {arn}"); + let another = restore_target_in_use_message("MusicRestored"); + // The backup's stored ARN, the request's `BackupArn`, the backup of the + // restore in progress, the text: the same backup as issued, trimmed, + // in another region and stored under an earlier `server.region`, then + // another backup. + let rows = [ + (&ours, ours.clone(), &ours, same(&ours)), + (&ours, format!(" {ours}\n"), &ours, same(&ours)), + (&ours, earlier.clone(), &ours, same(&ours)), + (&earlier, earlier.clone(), &earlier, same(&earlier)), + (&ours, ours.clone(), &b2, another), + ]; + for (stored, requested, restoring, text) in &rows { + let mut src = source(Some(definition("PROVISIONED"))); + src.backup_arn.clone_from(stored); + let fake = Fake::with_source(src); + *fake.restore_error.lock().unwrap() = Some(StorageError::TableBeingRestored { + table_name: "MusicRestored".to_owned(), + backup_arn: restoring.to_string(), + }); + let err = restore(&fake, restore_body(json!({ "BackupArn": requested }))) + .await + .unwrap_err(); + assert!( + matches!(&err, DynamoDbError::TableInUseException(m) if m == text), + "{requested:?} into a target of {restoring}: {err:?}" + ); + assert_eq!( + err.full_error_type(), + "com.amazonaws.dynamodb.v20120810#TableInUseException" + ); } - assert_eq!( - err.full_error_type(), - "com.amazonaws.dynamodb.v20120810#TableInUseException" - ); let fake = Fake::with_source(source(Some(definition("PROVISIONED")))); *fake.restore_error.lock().unwrap() = Some(StorageError::BackupInUse(format!( @@ -8254,7 +8273,8 @@ async fn restore_takes_the_permit_last() { /// overrides and the permit, the order the service uses: with every permit /// held and the backup restorable, a restore into a name a table has is /// TableAlreadyExists, a retry into a CREATING restore target is TableInUse -/// naming the target's source backup in the backend's own text, a CREATING +/// naming the target's source backup in the backend's own text (the +/// service's name-in-use text for a target of another backup), a CREATING /// table with no RestoreSummary (an ordinary create) and an ACTIVE former /// target (its summary no longer in progress) are TableAlreadyExists; the /// backup was read once and the backend not asked. With a missing backup, @@ -8300,19 +8320,26 @@ async fn restore_checks_the_target_name_after_the_backup_and_before_the_permit() (fake, err) } let restorable = || Fake::with_source(source(Some(definition("PROVISIONED")))); + // Each target with its TableInUse text, `None` for TableAlreadyExists. let targets = [ - table(TableStatus::Active, None), - table(TableStatus::Creating, None), - table(TableStatus::Creating, Some(&arn(ACCOUNT))), - table(TableStatus::Active, Some(&arn(ACCOUNT))), + (table(TableStatus::Active, None), None), + (table(TableStatus::Creating, None), None), + ( + table(TableStatus::Creating, Some(&arn(ACCOUNT))), + Some(format!( + "Table: MusicRestored is already being restored from backup: {}", + arn(ACCOUNT) + )), + ), + (table(TableStatus::Active, Some(&arn(ACCOUNT))), None), + ( + table(TableStatus::Creating, Some(&arn_n(2))), + Some(restore_target_in_use_message("MusicRestored")), + ), ]; // The backup restorable: the name's refusal, after one read of the backup. - let in_use_text = format!( - "Table: MusicRestored is already being restored from backup: {}", - arn(ACCOUNT) - ); - for (i, target) in targets.iter().enumerate() { + for (i, (target, in_use)) in targets.iter().enumerate() { let (fake, err) = check(restorable(), target.clone()).await; assert_eq!(fake.source_reads(), 1, "{i}: the backup was read first"); assert_eq!( @@ -8320,22 +8347,21 @@ async fn restore_checks_the_target_name_after_the_backup_and_before_the_permit() ["MusicRestored"], "{i}: the name was read once, under the request's spelling" ); - if i == 2 { - assert!( - matches!(err, DynamoDbError::TableInUseException(ref m) if *m == in_use_text), - "a CREATING restore target: {err:?}" - ); - } else { - assert!( + match in_use { + Some(text) => assert!( + matches!(err, DynamoDbError::TableInUseException(ref m) if m == text), + "{i}: a CREATING restore target: {err:?}" + ), + None => assert!( matches!(err, DynamoDbError::TableAlreadyExistsException(ref m) if m.contains("MusicRestored")), "{i}: {err:?}" - ); + ), } } // The backup missing: BackupNotFound whatever the target's state, and // the name is never read. - for (i, target) in targets.iter().enumerate() { + for (i, (target, _)) in targets.iter().enumerate() { let (fake, err) = check(Arc::new(Fake::default()), target.clone()).await; assert!( matches!(err, DynamoDbError::BackupNotFoundException(ref m) @@ -15127,7 +15153,7 @@ async fn the_registrations_refusals_keep_their_classes_and_return_the_slot() { ); let runtime = job_runtime(&mem); type Expected = fn(&DynamoDbError) -> bool; - let cases: [(StorageError, Expected); 4] = [ + let cases: [(StorageError, Expected); 5] = [ ( StorageError::TableAlreadyExists("MusicRestored".to_owned()), |e| matches!(e, DynamoDbError::TableAlreadyExistsException(_)), @@ -15137,7 +15163,22 @@ async fn the_registrations_refusals_keep_their_classes_and_return_the_slot() { table_name: "MusicRestored".to_owned(), backup_arn: arn(ACCOUNT), }, - |e| matches!(e, DynamoDbError::TableInUseException(_)), + |e| { + matches!(e, DynamoDbError::TableInUseException(m) if *m == format!( + "Table: MusicRestored is already being restored from backup: {}", + arn(ACCOUNT) + )) + }, + ), + ( + StorageError::TableBeingRestored { + table_name: "MusicRestored".to_owned(), + backup_arn: arn_n(2), + }, + |e| { + matches!(e, DynamoDbError::TableInUseException(m) + if *m == restore_target_in_use_message("MusicRestored")) + }, ), ( extenddb_storage::backup_catalog::backup_not_found(&arn(ACCOUNT)), @@ -15247,7 +15288,8 @@ async fn a_backup_being_restored_is_in_use_until_its_target_is_active() { .await .unwrap_err(); assert!( - matches!(err, DynamoDbError::TableInUseException(_)), + matches!(err, DynamoDbError::TableInUseException(ref m) + if *m == restore_target_in_use_message("MusicRestored")), "another backup into the name being restored into: {err:?}" ); gate.add_permits(1); @@ -20007,7 +20049,8 @@ async fn a_retry_waits_on_its_registration_and_another_backup_is_refused() { .await .unwrap_err(); assert!( - matches!(other, DynamoDbError::TableInUseException(_)), + matches!(other, DynamoDbError::TableInUseException(ref m) + if *m == restore_target_in_use_message("MusicRestored")), "{other:?}" ); assert_eq!(fake.restore_claims.lock().unwrap().len(), 1); diff --git a/crates/storage/src/backup_catalog.rs b/crates/storage/src/backup_catalog.rs index 384c09dbd..2e1d5094c 100644 --- a/crates/storage/src/backup_catalog.rs +++ b/crates/storage/src/backup_catalog.rs @@ -1015,13 +1015,21 @@ pub fn backup_in_use(table: &str, backup_arn: &str) -> StorageError { StorageError::BackupInUse(backup_in_use_message(backup_arn)) } +/// The text the service answers for a change to a CREATING restore target: +/// DeleteTable of it (measured on DynamoDB on 2026-11-21) and a restore of +/// another backup into its name (measured on 2026-11-22). +#[must_use] +pub fn restore_target_in_use_message(table_name: &str) -> String { + format!( + "Attempt to change a resource which is still in use: Table: {table_name} is being used." + ) +} + /// DeleteTable on a CREATING restore target, as every backend answers it -/// (`ResourceInUseException`, the text measured on DynamoDB on 2026-11-21). +/// (`ResourceInUseException`, [`restore_target_in_use_message`]). #[must_use] pub fn restore_target_in_use(table_name: &str) -> StorageError { - StorageError::IndexesInUse(format!( - "Attempt to change a resource which is still in use: Table: {table_name} is being used." - )) + StorageError::IndexesInUse(restore_target_in_use_message(table_name)) } /// The one signal of a missing backup every backend emits inside a diff --git a/docs/differences-from-dynamodb.md b/docs/differences-from-dynamodb.md index c44479284..adf09a670 100755 --- a/docs/differences-from-dynamodb.md +++ b/docs/differences-from-dynamodb.md @@ -120,7 +120,7 @@ Behaviour stated as measured, and every number below, was observed with release | Reads on a restore target | A `GetItem` or `Scan` on the target while `CREATING` is `ResourceNotFoundException`; the first read after `DescribeTable` reports `ACTIVE` succeeds (measured) | The same on all four backends. The server's key-info cache stores a negative entry (5 s TTL by default) for a name the catalog does not have, and does not store one for a name the catalog has in a state other than `ACTIVE`: on a not-found answer it asks the catalog once more with `DescribeTable`, and authorization records the name as missing in the key-info snapshot it hands the engine, so the engine does not look it up again. A `GetItem`, `PutItem`, `UpdateItem`, `DeleteItem`, `Query`, or `Scan` on the target while it is `CREATING` therefore costs exactly one `table_key_info` and one `describe_table` catalog load, uncached, per request (on SQLite five SQL statements: one for the key info, four for `DescribeTable`; on PostgreSQL `describe_table` is two queries), plus one `describe_table` on the first such request for the throttle registry; the first read after `ACTIVE` loads once more and is then cached. Measured on SQLite with a `GetItem` loop on a `CREATING` restore target of 100,000 items: 40 requests refused, 40 key-info and 41 `DescribeTable` loads in the server's statement log; with the hand-off to the engine removed, 80 and 81. In an earlier run of the fidelity test the first `GetItem` after `ACTIVE` answered in 3 ms after 72 refused reads. | | `RestoreTableFromBackup` overrides | Current request members are `BillingModeOverride`, `ProvisionedThroughputOverride`, `GlobalSecondaryIndexOverride`, `LocalSecondaryIndexOverride`, `SSESpecificationOverride`, `OnDemandThroughputOverride`, and `VectorIndexOverride`; DynamoDB applies them to the restored table | See the overrides table below. A refused override is refused before the target table is created | | Members of the `RestoreTableFromBackup` response | The `CREATING` description omits `DeletionProtectionEnabled`, the table's `ProvisionedThroughput.NumberOfDecreasesToday`, and each GSI's `IndexStatus` | The same on all four backends; `DescribeTable` reports the first two. Each GSI's `ProvisionedThroughput` keeps `NumberOfDecreasesToday`; what the service sends there was not measured | -| Restoring into a name that exists | `TableAlreadyExistsException`; into a name that is itself a `CREATING` restore target, `TableInUseException`: "Table: is already being restored from backup: " for the same backup, and "Attempt to change a resource which is still in use: Table: is being used." for a different one (both measured) | `TableAlreadyExistsException` on all four backends for an existing table; `TableInUseException` for a name that is a `CREATING` restore target, whichever backup is restored, always with the same-backup text naming the backup the existing target is being restored from (the service's text for a different backup is not reproduced). The engine checks the name after the backup is read and before the overrides are checked against it, the order the service uses: a restore of a missing backup into an existing table, into a table `CreateTable` is still creating or into a `CREATING` restore target is `BackupNotFoundException` "Backup not found: " (measured on DynamoDB, twice each, and the same on `main`); an earlier build of this release checked the name first and answered `TableAlreadyExistsException` or `TableInUseException` for those three. The name is still checked before the job permit is taken, so the answer does not depend on whether a permit is free; each backend checks the name again under its registration (a missing backup reaches the backend only when it is deleted after the engine has read it), whose target insert is the fence that tells an existing table from a `CREATING` target, so two simultaneous requests cannot both pass. The existing table or target is unchanged | +| Restoring into a name that exists | `TableAlreadyExistsException`; into a name that is itself a `CREATING` restore target, `TableInUseException`: "Table: is already being restored from backup: " for the same backup, and "Attempt to change a resource which is still in use: Table: is being used." for a different one (both measured) | `TableAlreadyExistsException` on all four backends for an existing table; `TableInUseException` for a name that is a `CREATING` restore target, with the service's same-backup text when the request names the backup the existing target is being restored from, and its different-backup text otherwise. The engine checks the name after the backup is read and before the overrides are checked against it, the order the service uses: a restore of a missing backup into an existing table, into a table `CreateTable` is still creating or into a `CREATING` restore target is `BackupNotFoundException` "Backup not found: " (measured on DynamoDB, twice each, and the same on `main`); an earlier build of this release checked the name first and answered `TableAlreadyExistsException` or `TableInUseException` for those three. The name is still checked before the job permit is taken, so the answer does not depend on whether a permit is free; each backend checks the name again under its registration (a missing backup reaches the backend only when it is deleted after the engine has read it), whose target insert is the fence that tells an existing table from a `CREATING` target, so two simultaneous requests cannot both pass. The existing table or target is unchanged | | `UpdateTable` on a `CREATING` restore target | `ResourceNotFoundException` (measured on DynamoDB) | `ResourceInUseException` on all four backends, the engine's mapping of a table that is not `ACTIVE`. A plain `CreateTable` into the target's name is `ResourceInUseException` "Table already exists: ", the service's text for a taken name (measured on DynamoDB), without the backup ARN. The target is unchanged | | `BackupArn` that is malformed or belongs to another account | Not an ARN of the right shape, too long (over 1024), a control character, a slash or `..` in the region: `ValidationException` "Invalid Request: BackupArn is not valid". The right shape with an id that is not a backup id (not hex, a wildcard): `ValidationException` "Invalid Backup ARN" (both measured; which input gets which text was captured for one input only: a bare 13-digit id is "Invalid Request: BackupArn is not valid"). Surrounding whitespace, a trailing newline for one, is trimmed, and an ARN naming another region of the caller's account resolves (measured). One in another partition is `ValidationException` (measured; text not captured) | The same two texts on all four backends, split by ExtendDB's parser: a string that is not `arn:aws:dynamodb:::table//backup/` with a region in `[a-z0-9-]`, a digit-only account, a name in `[a-zA-Z0-9_.-]`, only printable ASCII, and at most 1024 bytes after trimming is "Invalid Request: BackupArn is not valid" (so is one in a partition other than `aws`, the only one ExtendDB issues); one of that shape whose id is neither `[0-9]{14}-[0-9a-f]{8}` nor a shape an earlier build issued (13 digits, `-`, 8 hex digits, which every backend issued before the shared id; 13 bare digits, which PostgreSQL v0.1.0 to v0.1.2 issued) is "Invalid Backup ARN"; no build has put a UUID in a backup ARN, so none resolves. Surrounding ASCII whitespace is trimmed (only a trailing newline was measured on the service; trimming all surrounding whitespace is ExtendDB's generalisation), and the region is checked for shape only: the backup is looked up under the ARN rebuilt in this deployment's `server.region` first and, when that is not found and the caller wrote a different ARN, under the ARN as written, so another region's resolves and a backup created under an earlier `server.region` stays reachable by the ARN `ListBackups` reports for it, though not by that ARN rewritten with the new region (see the upgrade manual on `server.region`). A bare 13-digit id (the shape PostgreSQL v0.1.0 to v0.1.2 issued) passes the id check, so such an ARN that names no backup is `BackupNotFoundException`, where the service answers `ValidationException` "Invalid Request: BackupArn is not valid" (measured on DynamoDB). Under a `server.region` outside `[a-z0-9-]` no backup ARN can be formed, so `CreateBackup` is refused with a `ValidationException` naming `server.region`, and the backups taken before the upgrade under such a region keep an ARN the three operations refuse as "not valid"; the server starts and logs a warning saying so. A well-formed ARN naming another account, of any number of digits, is refused on `DescribeBackup`, `DeleteBackup`, and `RestoreTableFromBackup` before any policy is evaluated, in dev mode too, with the service's answers (see "A resource ARN in another account"). The same checks apply to `ListBackups`'s `ExclusiveStartBackupArn`, where another account's or region's cursor is instead a `ValidationException` (see `ListBackups` paging). In every build, dev mode included, `DescribeBackup` and `DeleteBackup` first refuse a `BackupArn` that does not parse as a backup ARN at all (a table ARN, an `xrn:` prefix, an empty field) with "Invalid Backup ARN" before any policy is evaluated, as the service does (measured on DynamoDB), so those shapes get that text instead of the engine's. Every other `BackupArn` is authorized as the backup it names in this deployment (the table and id, in the server's region and the caller's account, surrounding whitespace trimmed as the engine trims it) and then checked by the engine as above. Same on all four backends | | Tag conditions on backups | The backup resource has no `aws:ResourceTag` condition key: a backup has no tags to match | `DescribeBackup`, `DeleteBackup`, and `RestoreTableFromBackup` are authorized on the backup ARN as a resource with no tags. An `aws:ResourceTag/` condition finds the key absent for a backup (and `dynamodb:ResourceTag/` is absent for every resource), so, for example, an Allow conditioned on `StringEquals` never grants on a backup and a Deny conditioned on `StringEquals` never denies one. This holds whatever an earlier build stored under the backup ARN (it accepted `TagResource` on one; see Tagging), and a backup does not take its table's tags. For `RestoreTableFromBackup`, the seven item actions evaluated on `table/` (see the authorization rows below) read that ARN's resource tags. A target that does not exist has no tags, so an `aws:ResourceTag/` condition on those actions finds none and does not grant the restore; a target that exists is evaluated with its tags, and a request that is otherwise valid then passes authorization and fails `TableAlreadyExistsException` (or `TableInUseException` for a `CREATING` restore target) when the condition is met, and fails `AccessDeniedException` naming the first item action when it is not (measured on SQLite). Whether the service reads a target's tags in these evaluations was not measured. Scope backup permissions by ARN (`table//backup/*`). Measured on PostgreSQL and SQLite for the Allow case, including tags written under a backup ARN by the earlier build and then served by this one; the Deny case and role sessions rest on unit tests of the authorization path, which is the same for every backend |