Skip to content

fix(engine): answer the IndexName faults of both restore override lists - #1273

Open
LeeroyHannigan wants to merge 6 commits into
fix/1246-restore-target-typefrom
fix/1227-override-names-both-lists
Open

LeeroyHannigan wants to merge 6 commits into
fix/1246-restore-target-typefrom
fix/1227-override-names-both-lists

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

  • 3bfcef677e: DynamoDB checks no more index names once 10 constraints fail, and it lists every clause of the name that brings the count to 10. On 3 December 2026, nine g i and then a! got 11 clauses and the count 11, in one list and across the two lists. validate_name_members cut its list at 10 clauses and said 10. It now stops before the next name once 10 or more constraints fail. The constant is now CLAUSE_LIMIT, and its comment names the file of the PartiQL MAX_PARTS. Two more requests of the same day got the answer that this branch gave before the change and still gives. They have six names that fail both constraints, and 3 bad names in the LSI list with 100 in the GSI list. The engine test of both lists and the wire table of restore names get these four rows.
  • The description gives the new limit, the four measured rows and the test runs at the new head.

What

RestoreTableFromBackup now answers bad IndexName values in both override lists, or two in one list, with every fault in one ValidationException, as DynamoDB does. The entries of LocalSecondaryIndexOverride come first, then those of GlobalSecondaryIndexOverride, each list in entry order. Before this change, ExtendDB answered the first bad name of the GSI list alone.

The change is in IndexOverrides::check_index_names in crates/engine/src/backup/overrides.rs. It collects the names and member paths of both lists and calls validate_name_members. That new function in crates/core/src/validation/mod.rs holds the body of validate_name_member and loops over several members. validate_name_member calls it with one member, so its callers keep their answers. The bounds of an index name, 3 to 255, are now the constant INDEX_NAME_BOUNDS. A request with one bad name gets the same answer as before.

Once 10 constraints fail, the check takes no more names. It lists every clause of the name that brings the count to 10. So when more than 10 constraints fail, an answer lists 10 or 11 clauses in that order, and its count says the same. The limit is the constant CLAUSE_LIMIT in crates/core/src/validation/mod.rs. The PartiQL request checks list at most 10 clauses, with the limit MAX_PARTS, which is private to crates/engine/src/partiql/request_checks.rs. The core crate cannot read an engine constant, so the limit of 10 has two copies. #1110 adds a third, MAX_FAULTS in crates/engine/src/nested_enums.rs. Whichever of #1110 and #1273 merges second makes one constant serve both. #1365 adds a fourth, MAX_CLAUSES, at the same place in crates/core/src/validation/mod.rs, and the PartiQL request checks read it there. Each of these PRs that merges after another one drops its copy and reads the constant that is already on main.

The base of this PR is #1267, which holds the restore checks that this change extends.

Why

DynamoDB's answers, measured in us-east-1 on 20 November 2026. Each request went out twice, and every answer was a ValidationException. Each request names a backup that does not exist. L.n is localSecondaryIndexOverride.n.member.indexName and G.n is globalSecondaryIndexOverride.n.member.indexName. LEN is Member must have length greater than or equal to 3, and PAT is the pattern clause.

GSI names LSI names DynamoDB's clauses ExtendDB on #1267
ab g i L.1 PAT, G.1 LEN G.1 LEN
ab g i, with the LSI list first in the body L.1 PAT, G.1 LEN G.1 LEN
g i ab L.1 LEN, G.1 PAT G.1 PAT
ab ab L.1 LEN, G.1 LEN G.1 LEN
ab, g i none G.1 LEN, G.2 PAT G.1 LEN
none ab, g i L.1 LEN, L.2 PAT L.1 LEN
ab, cd g i L.1 PAT, G.1 LEN, G.2 LEN G.1 LEN
a! g i L.1 PAT, then G.1 PAT and LEN G.1 LEN, G.1 PAT
two U+1F600 g i L.1 PAT, then G.1 LEN and PAT G.1 LEN, G.1 PAT
ab a! L.1 LEN and PAT, then G.1 LEN G.1 LEN
a! a! L.1 LEN and PAT, then G.1 LEN and PAT G.1 LEN, G.1 PAT
100 g i 100 g i 10 validation errors detected:, L.1 PAT to L.10 PAT (3 December 2026) G.1 PAT
5000 g i 5000 g i the same 10 clauses (3 December 2026) G.1 PAT
six a! none 10 validation errors detected:, G.1 to G.5, each LEN and PAT (3 December 2026) G.1 LEN, G.1 PAT
100 g i 3 g i 10 validation errors detected:, L.1 to L.3 PAT, then G.1 to G.7 PAT (3 December 2026) G.1 PAT
nine g i, then a! none 11 validation errors detected:, G.1 to G.9 PAT, then G.10 LEN and PAT (3 December 2026) G.1 PAT
two a! nine g i 11 validation errors detected:, L.1 to L.9 PAT, then G.1 LEN and PAT (3 December 2026) G.1 LEN, G.1 PAT

For a name that fails both constraints, the order of its two clauses changed between the two sends of some requests. ExtendDB keeps its own order for them, the length clause first. Four more measured requests have one bad name, and ExtendDB answered them as DynamoDB does before and after this change. With this change, ExtendDB answers all 21 measured requests as DynamoDB does.

Fixes #1227

Testing done

At 3bfcef677e, each cargo command with --locked:

  • cargo +1.97.0 test -p extenddb-core -p extenddb-engine --lib: core 1259 passed and 1 ignored, engine 983 passed.
  • cargo +1.97.0 fmt --all -- --check is clean. cargo +1.97.0 clippy -p extenddb-core -p extenddb-engine --all-targets -- -D warnings is clean, and so is the same command with --features extenddb-engine/backup-test-hooks. cargo +1.94.0 check -p extenddb-core -p extenddb-engine --all-targets is clean. cargo +1.97.0 test -p extenddb-wasm-adapter: the 3 unit tests and the parity test pass.
  • The unit test the_index_name_faults_of_both_override_lists_are_answered_together has 9 rows. In two rows each list has one bad name, and the two faults change places between the lists. One row has two bad names in one list, and one row has a name that fails both constraints in each list. One row has 11 bad names in each list and gets the first 10 clauses of the LSI list. The other four are the rows of 3 December. They have six a!, then 3 bad names in the LSI list with 100 in the GSI list, and then the two rows of 11 clauses. The unit test builds the body as a JSON object, so it cannot send the LSI list first. The wire table has that row. With the truncate of ad80b47 in place of the new check, the test fails at the row of nine g i and a!. That row then gets the length clause of G.10 alone. With no limit, or with one more name after 10 failed constraints, it fails at the row of 11 in each list.
  • The wire runs used servers built from this commit before its last edit, which changed only the doc comment of CLAUSE_LIMIT. Against ExtendDB on SQLite and on PostgreSQL, tests/test_backup_restore_fidelity.py passed its 37 tests on each backend. One of them reads EXTENDDB_TEST_BACKUP_STORE and passed in a second run with it set to none. The table of restore names now has 17 measured rows. Against a SQLite server built with the truncate of ad80b47, test_backup_and_table_names_are_validated fails at a row of 11 clauses. The four requests of 3 December got DynamoDB's answers from the SQLite server of this commit. The check compared each clause, with one name's two clauses as a set. pytest --collect-only -q collects 7301 tests in tests/ and 820 in tests/python, with no error.

At ad80b47929:

  • cargo +1.97.0 test -p extenddb-core -p extenddb-engine -p extenddb-server -p extenddb-storage --lib: core 1259 passed and 1 ignored, engine 983 passed, server 522 passed and 5 failed, storage 294 passed. On this host 5 backup_store::tests fail on every branch, because uid 65534 owns /local/home. So the server lib has 527 tests, and 522 of them pass here.
  • cargo +1.94.0 check of the four crates with --all-targets is clean. The parity test passes over the 279 cases of the corpus. The clippy step of the WebAssembly workflow, run on this branch, is clean.
  • Against ExtendDB on SQLite built from this head, 215 wire tests passed: tests/test_backup_restore_fidelity.py 37, tests/test_continuous_backups.py 9, tests/test_authz_cross_account.py 19, tests/test_authz_resource_arn.py 49, tests/python/test_nul_table_name_fields.py 52, tests/python/test_nul_arn_shapes.py 48 and tests/python/test_warm_throughput_backup.py 1. The 46 tests of tests/test_backup_job.py skipped, because they start their own server from EXTENDDB_BINARY and these runs did not set it. The same server gave the two restores of 3 December, with 100 and with 5000 bad names in each list, DynamoDB's 1620-character answer. pytest --collect-only -q collects 7301 tests in tests/ and 820 in tests/python, with no error.
  • The table of restore names in tests/test_backup_restore_fidelity.py gets 13 rows from the measurements. Against a server built from 8022210a8, the fix(server): refuse a restore's TargetTableName of another JSON type first #1267 head that this branch started from, the 12 rows of 20 November failed.
  • On an earlier revision of this commit, every other caller of validate_name_member and validate_index_name gave the same answer as on 8022210a8, for 20 requests. The callers are CreateTable, UpdateTable, CreateBackup, ListBackups, both ContinuousBackups operations and both restores. That revision differs from d7717df88 only in the tests and in the place of one use line.

Line counts: production +64 -23, tests +160 -7.

This PR adds a conflict with #1228 in crates/core/src/validation/mod.rs. #1228 changes the pattern check that this PR moves into the loop of validate_name_members. When the second of the two PRs merges, the value.is_empty() || condition of #1228 goes inside that loop.

It also conflicts with #1353, #1358, #1359, #1365, #1367 and #1373 in crates/core/src/validation/mod.rs, and the last three conflict in crates/engine/src/backup/overrides.rs as well. #1353 sits on #1327, and each of the others sits on the one before it, so none of them contains this commit. #1353 changes the body of validate_name_member too: it adds validate_name_member_after, which lists the clauses of other members first. The PR that merges second takes both changes and combines validate_name_members and validate_name_member_after into one helper. #1284, #1291 and #1327 merge cleanly with this head. This PR adds no conflict with main.

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 RestoreTableFromBackup with bad IndexName values in both override lists, or two in one list, gets every fault in one ValidationException, the LSI list first. When more than 10 constraints fail, the list stops at the name that brings the count to 10. Before this change, it got the first fault of the GSI list alone. A request with one bad name gets the same answer 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.

RestoreTableFromBackup with a bad IndexName in a
GlobalSecondaryIndexOverride entry and another in a
LocalSecondaryIndexOverride entry answered only the GSI entry's fault.
DynamoDB lists every fault in one answer. It gives the LSI list first,
then the GSI list, each in entry order, whatever the order of the two
members in the body. Two bad names in one list are both listed too.
Measured in us-east-1 on 20 Nov 2026.

check_index_names now collects the faults of both lists in that order
and answers them under one "N validation errors detected" header. A
name that fails both the length and the pattern keeps ExtendDB's order
of its two clauses. A request with one bad name gets the answer it got
before. validate_name_members in core checks several members and
answers them in one message, and validate_name_member calls it with
one member.

Fixes #1227.
The docstring of test_backup_and_table_names_are_validated said that
the test checks the order of the two clauses of one name exactly on
ExtendDB. The rows with names in both override lists compare the two
clauses of one name as a set on ExtendDB too. The docstring now says
so.

@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 the answer has no limit on how many faults it lists. Before this change a request with thousands of bad names got the first fault back. On a SQLite build of this head, 5000 bad entries in each list get a 1,482,889 byte answer that says "10000 validation errors detected", and the same request on the base (#1267 merged with main) gets 244 bytes. Has anyone sent a long list of bad names to DynamoDB to see whether it lists every one or stops at a count?

CI did not finish on this head. run-tests (stable) was cancelled, and test, integration, cassandra-integration and mongodb-integration fail or were cancelled behind it. run-tests (1.91.1) fails in extenddb-auth secmem::tests::init_refuses_under_a_low_memlock_limit_then_starts_unlocked, a test this PR does not touch that also failed on main on 26 Nov and passes there now. wasm fails on the E0308 that #1482 fixed. I merged current main into this head locally: no conflict, and the core (1242), engine (980) and server (527) lib tests pass. Could you merge main so the unit test legs run on a tree without those two main failures?

The description says "server 515 passed". I count 520 on this head with cargo +1.97.0 test --locked -p extenddb-server --lib. Could you check which number is right?

I will approve once main is merged and CI is green on it.

…lists

The parent branch now contains main at b3510a9.

Conflict in crates/engine/src/backup/tests.rs: this branch and
fix/1224-restore-target-name each add a test after
an_index_override_name_is_checked_before_the_backup_is_read. This merge
keeps both tests.
validate_name_members listed every failed constraint, so a restore with
5000 bad names in each override list got all 10000 faults in its
answer. DynamoDB lists the first 10 and its count says 10. It gave the
same 1620-character answer to 100 and to 5000 bad names in each list
(measured in us-east-1 on 3 Dec 2026). validate_name_members now keeps
the first 10 clauses.

The engine test of both override lists and the wire table of restore
names get a row with over 10 bad names in each list.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@navareamol

@navareamol

Copy link
Copy Markdown
Collaborator

The cap counts failed constraints, not names. A name that fails both constraints, such as a!, takes two of the ten, so six of them give five names and ten clauses (the length text and the pattern text for each of the first five). Your 3 December rows used names that fail one constraint, g i, so they do not say whether DynamoDB counts constraints or names. A split list is the same: with 3 bad names in the LSI list and 100 in the GSI list, this branch lists the 3 LSI clauses and the first 7 GSI clauses. Has anyone sent a request with names that fail both constraints, or with a split like that, to DynamoDB? If not, I think the comment on MAX_LISTED_CLAUSES should say those two cases are not measured.

The comment says to keep the same limit as MAX_PARTS. There are two constants with that name, one in crates/engine/src/partiql/request_checks.rs and one in crates/backup-store/src/s3.rs that is 10000. Naming the file in the comment would stop a reader from landing on the wrong one.

The cap itself works as described. On a SQLite build of this head merged with current main, 5000 bad names in each list get a 1551 byte answer that says 10 validation errors detected, where the base gave 1,482,889 bytes. 9 bad names say 9, and 10 or 11 say 10. A bad name at position 11 after ten valid ones is reported at position 11. A bad BillingModeOverride and a null BackupArn still win over the name faults. validate_name_members is only called from the restore overrides, so the other name checks answer as before. If I remove the truncate, or set the limit to 9 or 11, the engine test fails. The DynamoDB numbers are your measurements.

Main is merged and every check on ad80b47 is green. The server test count of 515 against 520 is explained by the 5 backup_store tests that fail on your host, and the body now gives both numbers.

I will approve once the two constraint case and the split list are measured, or the comment says they are not.

DynamoDB checks no more index names after 10 constraints fail, and it
lists every clause of the name that brings the count to 10. Nine names
that fail one constraint, then a name that fails both, get 11 clauses and
the count 11. This holds in one list and across the two lists (measured
in us-east-1 on 3 December 2026). validate_name_members cut its list at
10 clauses, so it left out the second clause of that name and its count
said 10.

The loop now stops before the next member once 10 or more constraints
fail. The constant is CLAUSE_LIMIT. Its comment gives the measured cases
and names the file that holds the PartiQL MAX_PARTS.

The engine test of both lists and the wire table of restore names get
four rows measured on 3 December 2026:

- six names that fail both constraints
- 3 bad names in the LSI list and 100 in the GSI list
- the two rows of 11 clauses

The engine test keeps its row of 11 bad names in each list in the same
table.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@navareamol I sent both cases to DynamoDB in us-east-1 on 3 December 2026, each request twice, on names that do not exist. I also sent the case where the tenth failed constraint is the first clause of a name that fails both.

  • Six a! in the GSI list: 10 validation errors detected, the two clauses of G.1 to G.5. The cap counts failed constraints, as you said. This branch gives the same answer.
  • 3 bad names in the LSI list and 100 in the GSI list: L.1 to L.3, then G.1 to G.7, count 10. This branch gives the same answer.
  • Nine g i and then a! in the GSI list: 11 validation errors detected, G.1 to G.9 and both clauses of G.10. Nine g i in the LSI list and two a! in the GSI list: 11 too, L.1 to L.9 and both clauses of G.1. So DynamoDB checks no more names once 10 constraints fail, and it lists every clause of the name that gets there. This branch cut the list at 10, so it left out the second clause and said 10.

3bfcef6 fixes that. In place of the truncate, validate_name_members now stops before the next name once 10 or more constraints fail. The constant is now CLAUSE_LIMIT. Its comment gives these cases and names crates/engine/src/partiql/request_checks.rs as the file of MAX_PARTS.

The four rows are in the table of the_index_name_faults_of_both_override_lists_are_answered_together and in the wire table of restore names. The engine table now also holds the case of 11 bad names in each list. With the truncate of ad80b47 put back, the engine test fails at the row of nine g i and a!. G.10 then gets its length clause alone. The wire table fails too, against a SQLite server built that way. With no limit, or with one more name after 10 failed constraints, the engine test fails at the row of 11 in each list.

The two clauses of one name came in either order between the two sends of the six a!. So the rows compare them as a set, as the other rows do.

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

The code and the tests at 3bfcef6 give the answers you measured, and the comments match. I built this head on SQLite, ran the core and engine unit tests, and sent RestoreTableFromBackup requests with a string TargetTableName and a missing BackupArn.

  1. The four cases. Six "a!" in the GSI list answers "10 validation errors detected" with both clauses of G.1 to G.5. Three bad names in the LSI list and 100 in the GSI list answers L.1 to L.3 and G.1 to G.7, count 10. Nine "g i" and then "a!" in the GSI list answers 11, with G.1 to G.9 and both clauses of G.10. Nine "g i" in the LSI list and two "a!" in the GSI list answers 11, with L.1 to L.9 and both clauses of G.1. All four match your statements about DynamoDB, which I did not repeat on the live service.

  2. Other shapes, which I sent only to this branch. 100 bad names in each list answers L.1 to L.10, count 10, and 11 in each list answers the same. Four "a!" in each list answers L.1 to L.4 and G.1, count 10. Ten "g i" and then "a!" answers G.1 to G.10 and stops. Eight "g i" and then two "a!" answers G.1 to G.8 and both clauses of G.9. Nine "g i", a valid name and then "a!" answers 11 clauses with the last at G.11. Each of these follows the rule "no more names once 10 constraints have failed". Nobody has sent them to DynamoDB, so they show what this branch does and not what DynamoDB does.

  3. The tests. The core unit tests give 1259 passed and the engine unit tests give 983 passed, with no failure. I changed validate_name_members in four ways, one at a time, and the engine test the_index_name_faults_of_both_override_lists_are_answered_together failed for each: no limit (22 validation errors detected), the old truncate to 10 with no stop (it fails at the row of nine "g i" and "a!"), a stop only after more than 10 failed constraints (11 for the rows of 11 bad names), and a limit of 9 or 11. The tree was clean after each. I did not rerun the wire table with the old truncate.

  4. The comments. The doc of CLAUSE_LIMIT lists the measured cases, and each one matches what I sent. It names crates/engine/src/partiql/request_checks.rs for MAX_PARTS, and that file has MAX_PARTS = 10 and truncates to it, as the comment says.

All 70 checks pass on 3bfcef6, so I approve.

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