Repository navigation
fix(engine): give RestoreTableFromBackup override conflicts DynamoDB's texts - #1096
LeeroyHannigan wants to merge 2 commits into
Conversation
…s texts RestoreTableFromBackup refused an override that conflicts with the indexes or the billing mode of the backup with texts of ExtendDB's own. DynamoDB answers each conflict with an "Invalid Request: " sentence, and a throughput member below 1 with the model's constraint text. For the issue's requests that hold an on-demand maximum and another throughput conflict, DynamoDB reports the on-demand maximum, and ExtendDB reported the other conflict. The restore now gives DynamoDB's answer to each request measured in us-east-1 on 13, 14 and 17 Nov 2026. It checks the table's throughput before the index lists. For the table and for each GSI entry, it checks the on-demand maximum before the provisioned throughput. With BillingModeOverride PROVISIONED, it refuses a GSI entry without a throughput for the missing throughput first. It now accepts an on-demand maximum that sets no member on a PROVISIONED restore, as DynamoDB does. The overrides table of docs/differences-from-dynamodb.md lists the texts. Fixes #1048.
#1009 moved the backup list code, which reads `BackupSummary`, out of `crates/engine/src/backup.rs`, and this branch removed the `CreateTableInput` literal from that file. The merge keeps the `extenddb_core::types` import list without either name.
LJMart11
left a comment
There was a problem hiding this comment.
Reviewed at 7ae1efa. cargo test -p extenddb-engine --lib passed 890 tests; 10 mutations of the new throughput and index checks each failed a backup test. One docs item remains: the stated refusal order for OnDemandThroughputOverride.
1 finding is left inline.
| | `OnDemandThroughputOverride` | Applied on an on-demand restore, as on the service (measured on DynamoDB): equal to the backup's, changed, with one member, or on a `PROVISIONED` backup restored with `BillingModeOverride` `PAY_PER_REQUEST`. It replaces the backup's on-demand throughput as a whole: a member left out means no maximum, as on `CreateTable`, so `{}` restores a table with no maxima. On a `PROVISIONED` restore (from a `PROVISIONED` backup or by override) it is refused with `ValidationException`, as is a member other than `MaxReadRequestUnits` and `MaxWriteRequestUnits`. Measured on SQLite | | ||
| | `GlobalSecondaryIndexOverride` | Applied as the service applies it (measured on DynamoDB): the list replaces the backup's GSIs. An empty list restores no GSI; a subset restores those, in the list's order; each entry's `ProvisionedThroughput` is the restored index's. The attribute definitions only dropped indexes used are dropped with them. Each entry must name a GSI of the backup, once, with its `KeySchema` (in order) and `Projection` (`NonKeyAttributes` compared as a set: any order, and an entry with a duplicate is accepted): an index the backup does not have, one listed twice, or a changed `KeySchema` or `Projection` is `ValidationException` naming the index, as on the service (ExtendDB cannot restore an index the backup did not record). For an index the backup does not have and for a changed `Projection` the text is the service's, "Invalid Request: Index <name> does not match a secondary index that existed in the source table and cannot be created during the restore operation"; for an index listed twice and a changed `KeySchema` it is ExtendDB's own, the service's text not measured. On a `PROVISIONED` restore an entry without `ProvisionedThroughput` is `ValidationException` "Invalid Request: Must override ProvisionedThroughput if BillingMode is overridden to PROVISIONED for index <name>" when `BillingModeOverride` is `PROVISIONED`, and "Invalid Request: Must specify provisioned throughput for index <name>" when the backup is `PROVISIONED` and no `BillingModeOverride` is given. On an on-demand restore an entry's `ProvisionedThroughput` is refused with "Invalid Request: Cannot override ProvisionedThroughput if BillingMode is overridden to PAY_PER_REQUEST for index <name>" when `BillingModeOverride` is `PAY_PER_REQUEST`, and with "Invalid Request: Cannot override ProvisionedThroughput unless BillingMode is PROVISIONED for index <name>" without one. An entry's `OnDemandThroughput` that sets a member `<m>` (`MaxReadRequestUnits`, else `MaxWriteRequestUnits`) is refused ahead of a given or missing `ProvisionedThroughput` beside it. When `BillingModeOverride` is `PROVISIONED`, a missing `ProvisionedThroughput` is refused first. The texts are "Invalid Request: Cannot override <m> for OnDemandThroughput when BillingMode is PROVISIONED for index <name>" when `BillingModeOverride` is `PROVISIONED`, and without the override "... when ProvisionedThroughputOverride is present for index <name>" beside a `ProvisionedThroughput` and "... unless BillingModeOverride is PAY_PER_REQUEST for index <name>" on a `PROVISIONED` backup without one. Otherwise, on an on-demand restore, an entry's `OnDemandThroughput` is accepted and not recorded (ExtendDB keeps no per-index on-demand maximum; the service applies it). On a `PROVISIONED` restore, an entry's `OnDemandThroughput` that sets no member is accepted beside a `ProvisionedThroughput` (measured on a `PROVISIONED` backup without `BillingModeOverride`). Without one, the entry is refused for the missing `ProvisionedThroughput`, as above. These are the service's texts and order, measured on DynamoDB on 13, 14 and 17 Nov 2026. `{0, 0}` is refused, as `CreateTable` refuses it on a `PROVISIONED` restore and as any `ProvisionedThroughput` on an on-demand one, so the list `DescribeBackup`'s `SourceTableFeatureDetails` gives is accepted as is for a `PROVISIONED` backup, and with `ProvisionedThroughput` left out for an on-demand one (the model requires at least 1 per member; boto3 and the AWS CLI refuse `{0, 0}` before sending). An entry with a member outside the model (`WarmThroughput`, for one) is refused with `ValidationException`; what the service does with it was not measured. Measured on SQLite | | ||
| | `LocalSecondaryIndexOverride` | As `GlobalSecondaryIndexOverride`, with `IndexName`, `KeySchema`, and `Projection` only: an empty list restores no LSI, a subset restores those, an unknown or changed index is refused (an unknown index and a changed `Projection` with the service's "Invalid Request: Index <name> does not match a secondary index that existed in the source table and cannot be created during the restore operation", measured on DynamoDB on 13 and 14 Nov 2026) | | ||
| | `OnDemandThroughputOverride` | Applied on an on-demand restore, as on the service (measured on DynamoDB): equal to the backup's, changed, with one member, or on a `PROVISIONED` backup restored with `BillingModeOverride` `PAY_PER_REQUEST`. It replaces the backup's on-demand throughput as a whole: a member left out means no maximum, as on `CreateTable`, so `{}` restores a table with no maxima. A member `<m>` (`MaxReadRequestUnits`, else `MaxWriteRequestUnits`) is refused with "Invalid Request: Cannot override <m> for OnDemandThroughput when BillingMode is PROVISIONED" when `BillingModeOverride` is `PROVISIONED`, and without the override with "... when ProvisionedThroughputOverride is present" beside a `ProvisionedThroughputOverride` and with "... unless BillingModeOverride is PAY_PER_REQUEST" on a `PROVISIONED` backup without one. It is checked first, ahead of the `ProvisionedThroughputOverride` and index refusals of the same request. `{}` on a `PROVISIONED` restore is accepted, and the table is restored with no maximum. These are the service's answers, measured on DynamoDB on 13, 14 and 17 Nov 2026 (`{}` on a `PROVISIONED` backup without `BillingModeOverride`). A member other than `MaxReadRequestUnits` and `MaxWriteRequestUnits` is refused with ExtendDB's own text. Measured on SQLite | |
There was a problem hiding this comment.
This row says OnDemandThroughputOverride "is checked first, ahead of the ProvisionedThroughputOverride and index refusals", but validate_override_shape (backup.rs:1051) runs before it. Through the row harness, BillingModeOverride PROVISIONED with OnDemandThroughputOverride {MaxReadRequestUnits: 10} and no throughput is refused with "Must override ProvisionedThroughput if BillingMode is overridden to PROVISIONED", not the on-demand text, on an indexed on-demand backup. If that order is the measured one, saying so here (as the GSI row already does for its entries) and adding that row to table_throughput_overrides_are_refused_with_the_services_texts would close it.
navareamol
left a comment
There was a problem hiding this comment.
I think {} as an on-demand maximum is now accepted on more requests than were measured. The description says DynamoDB accepts it "on a PROVISIONED backup without BillingModeOverride". check_throughput only refuses when a member is set, so it also accepts {} when an on-demand backup is restored with BillingModeOverride PROVISIONED. I ran restored_input on an on-demand backup with BillingModeOverride PROVISIONED, ProvisionedThroughputOverride {1, 1} and OnDemandThroughputOverride {}. Main refuses it ("OnDemandThroughputOverride can only be specified when the restored table's BillingMode is PAY_PER_REQUEST") and this branch restores it as PROVISIONED. The same holds for a GSI entry with ProvisionedThroughput {1, 1} and OnDemandThroughput {}. DynamoDB uses a different sentence when BillingModeOverride is PROVISIONED, so this may be a separate check. Has anyone sent these two requests to DynamoDB? If not, could you measure them, or keep refusing {} when BillingModeOverride is PROVISIONED?
The GSI row in docs/differences-from-dynamodb.md and the module comment in overrides.rs say the service's text for a changed KeySchema and for an index listed twice was not measured. Both were measured on 17 Nov ("Index gsi1 does not match a secondary index ..." and "Cannot have two or more indexes with name gsi1"). Could you say that ExtendDB's text differs there? Or return index_mismatch(name) for a changed KeySchema in same_definition, which is one line.
Backup::OnDemand in override_refusals.rs says "On demand, no index." but keeps the gpk and lsk attribute definitions. When I disabled the table throughput check, row 1 failed with "Number of attributes in KeySchema does not exactly match number of attributes defined in AttributeDefinitions", so a request on that backup that passes the override checks is refused by CreateTable validation. Trimming the definitions to pk and sk in backup() fixes it.
I will approve once the {} case under BillingModeOverride PROVISIONED is measured or refused, and the two doc sentences are corrected.
What
RestoreTableFromBackup now gives DynamoDB's texts when it refuses an override that conflicts with the indexes or the billing mode of the backup.
Invalid Request:sentence. For a GSI entry, the sentence ends infor index <name>.1 validation error detected: Value '0' at 'provisionedThroughputOverride.readCapacityUnits' failed to satisfy constraint: Member must have value greater than or equal to 1. When both members are below 1, the text nameswriteCapacityUnitsfirst.Projection, getInvalid Request: Index <name> does not match a secondary index that existed in the source table and cannot be created during the restore operation.Where DynamoDB checks in another order, the order changes too:
BillingModeOverridePROVISIONED, a GSI entry that has an on-demand maximum and no throughput gets the missing throughput text.An
OnDemandThroughputOverrideof{}on a PROVISIONED restore, and a GSI entry'sOnDemandThroughputof{}there, are now accepted. DynamoDB accepts both on a PROVISIONED backup withoutBillingModeOverride. The restored table and index get no on-demand maximum.In
crates/engine/src/backup/overrides.rs,check_throughputchecks the throughput of the table and of each GSI entry. It replacesvalidate_override_for_sourceinbackup.rs.throughput_requiredgives both missing throughput texts, andindex_mismatchgives theIndex <name> does not match ...text. The restore from the catalog and the restore from a backup store (restore.rs) call the same checks. The overrides table ofdocs/differences-from-dynamodb.mdgives the texts and the order.Why
These are DynamoDB's answers, measured in us-east-1. The 17 rows of the issue were measured on 13 and 14 November 2026, with each request sent four times. Seven more requests were measured on 17 November 2026 and sent twice each. Every request got the same answer on each send. Before this change, ExtendDB answered most of these conflicts with
One or more parameter values were invalid:and a text of its own. For two requests it reported a different conflict than DynamoDB does.Closes #1048
Testing done
cargo test -p extenddb-engine --lib: 870 passed.cargo test -p extenddb-core --lib: 1146 passed, 1 ignored.cargo +1.97.0 clippy -p extenddb-engine --all-targets -- -D warningsandcargo fmt --checkare clean.The wire tests ran on the previous revision of the commit, which differs only in Rust tests and one sentence of the docs. Against ExtendDB on SQLite with no backup store:
tests/test_restore_override_refusals.pypassed 25 tests: 23 refused requests and 2 accepted ones.tests/test_backup_restore_fidelity.pypassed 37 tests, andtests/python/test_warm_throughput_backup.pypassed 1.tests/python/test_nul_arn_shapes.pyandtests/python/test_nul_table_name_fields.pypassed 7.CI's PostgreSQL and SQLite integration jobs run the wire files with a filesystem backup store.
Line counts over main after the merge, with the lines after
#[cfg(test)]counted as tests: production +188 -124, tests +611 -177, docs +5 -5.Other open PRs:
crates/engine/src/backup/tests.rs: fix(engine): check a restore's override values in DynamoDB's order #1353, fix(server): answer the account of a BackupArn before its shape #1358, fix(engine): answer a restore from another region as DynamoDB does #1359, fix(engine): answer missing restore override members as DynamoDB does #1365, fix(engine): refuse a BackupArn table segment of a bad length #1367, fix(engine): answer a ListBackups cursor with DynamoDB's texts #1373 and fix(core): name the capacity member and value when it is below 1 #1442. In each, the conflict is the block where this PR removes the unit testsprovisioned_override_without_throughput_is_refusedandthroughput_override_under_pay_per_request_is_refusedand the other PR adds tests after them. The head before the merge with main has the same conflicts.--features pitr, the feature #934 adds. Itscrates/engine/src/backup/pitr/restore.rscallsvalidate_override_for_source, which this PR removes. It also passes the billing mode toIndexOverrides::apply, which now takes&RestoreTableOverrides. The PR that merges second removes that call and passes&members.overrides. #934'sPROVISIONED_NEEDS_THROUGHPUTholds the same text asthroughput_required(None, Some(BillingMode::Provisioned)). The merge keepsthroughput_requiredand removes #934's constant. With these edits,cargo check -p extenddb-engine --features pitrpasses on the merge of both. RestoreTableToPointInTime then gives the texts above, which were not measured for that operation.DynamoDB answers five more override requests differently from ExtendDB, and this PR does not change them. They are a
BackupArnthat names no backup, an index entry with anotherKeySchema, an index listed twice, and two index throughputs below 1. The issue does not list them, so #1097 lists them with their measurements.Merge of 25 November
#1009 merged first.
7ae1efa19mergesmainata417b2f82. #1009 moved the backup list code, which readsBackupSummary, out ofcrates/engine/src/backup.rs. This branch removed theCreateTableInputliteral from that file. The merge keeps theextenddb_core::typesimport list without either name. At7ae1efa19,cargo test -p extenddb-engine --libpassed 890 tests, andcargo test -p extenddb-wasm-adapterpassed its 3 unit tests and the parity corpus.cargo check -p extenddb-engine --no-default-features --lib, clippy with-D warningson the engine crate andcargo fmt --checkare clean. The cargo commands ran with--locked.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
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.