Skip to content

fix(engine): give RestoreTableFromBackup override conflicts DynamoDB's texts - #1096

Open
LeeroyHannigan wants to merge 2 commits into
mainfrom
fix/1048-restore-override-texts
Open

LeeroyHannigan wants to merge 2 commits into
mainfrom
fix/1048-restore-override-texts

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

What

RestoreTableFromBackup now gives DynamoDB's texts when it refuses an override that conflicts with the indexes or the billing mode of the backup.

  • Each conflict gets an Invalid Request: sentence. For a GSI entry, the sentence ends in for index <name>.
  • A throughput member below 1 gets the model's constraint text, for example 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 names writeCapacityUnits first.
  • An index that the backup does not have, and an index entry with another Projection, get Invalid 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:

  • The table's throughput checks run before the index list checks.
  • For the table and for each GSI entry, the restore refuses an on-demand maximum before a provisioned throughput.
  • With BillingModeOverride PROVISIONED, a GSI entry that has an on-demand maximum and no throughput gets the missing throughput text.

An OnDemandThroughputOverride of {} on a PROVISIONED restore, and a GSI entry's OnDemandThroughput of {} there, are now accepted. DynamoDB accepts both on a PROVISIONED backup without BillingModeOverride. The restored table and index get no on-demand maximum.

In crates/engine/src/backup/overrides.rs, check_throughput checks the throughput of the table and of each GSI entry. It replaces validate_override_for_source in backup.rs. throughput_required gives both missing throughput texts, and index_mismatch gives the Index <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 of docs/differences-from-dynamodb.md gives 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 warnings and cargo fmt --check are clean.
  • The Rust row tables send each request on both restore paths and check that both give the same answer.

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.py passed 25 tests: 23 refused requests and 2 accepted ones.
  • tests/test_backup_restore_fidelity.py passed 37 tests, and tests/python/test_warm_throughput_backup.py passed 1.
  • The restore tests of tests/python/test_nul_arn_shapes.py and tests/python/test_nul_table_name_fields.py passed 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:

DynamoDB answers five more override requests differently from ExtendDB, and this PR does not change them. They are a BackupArn that names no backup, an index entry with another KeySchema, 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. 7ae1efa19 merges main at a417b2f82. #1009 moved the backup list code, which reads BackupSummary, out of crates/engine/src/backup.rs. This branch removed the CreateTableInput literal from that file. The merge keeps the extenddb_core::types import list without either name. At 7ae1efa19, cargo test -p extenddb-engine --lib passed 890 tests, and cargo test -p extenddb-wasm-adapter passed its 3 unit tests and the parity corpus. cargo check -p extenddb-engine --no-default-features --lib, clippy with -D warnings on the engine crate and cargo fmt --check are clean. The cargo commands ran with --locked.

Checklist

  • I have read CONTRIBUTING.md
  • All tests pass (cargo test --workspace)
  • Code is formatted (cargo fmt --check)
  • Clippy is clean (cargo clippy -- -W clippy::pedantic)
  • I have added or updated tests for new functionality
  • I have updated documentation if behavior changed
  • Breaking changes are noted below (if any)
  • If this changes the wire protocol, Storage trait, auth model, on-disk
    format, or public CLI surface, an RFC has been accepted or is linked
    below. Otherwise, an ADR captures the decision (link below).

ADR / RFC: n/a


By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.

…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 LJMart11 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 navareamol left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think {} 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.

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.

RestoreTableFromBackup refuses a conflicting index or throughput override with ExtendDB's own texts, where DynamoDB answers Invalid Request: ...

3 participants