Repository navigation
fix(engine): answer the IndexName faults of both restore override lists - #1273
LeeroyHannigan wants to merge 6 commits into
Conversation
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
left a comment
There was a problem hiding this comment.
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.
|
|
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.
|
@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.
3bfcef6 fixes that. In place of the The four rows are in the table of The two clauses of one name came in either order between the two sends of the six |
navareamol
left a comment
There was a problem hiding this comment.
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.
-
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.
-
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.
-
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.
-
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.
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, nineg iand thena!got 11 clauses and the count 11, in one list and across the two lists.validate_name_memberscut its list at 10 clauses and said 10. It now stops before the next name once 10 or more constraints fail. The constant is nowCLAUSE_LIMIT, and its comment names the file of the PartiQLMAX_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.What
RestoreTableFromBackup now answers bad
IndexNamevalues in both override lists, or two in one list, with every fault in one ValidationException, as DynamoDB does. The entries ofLocalSecondaryIndexOverridecome first, then those ofGlobalSecondaryIndexOverride, 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_namesincrates/engine/src/backup/overrides.rs. It collects the names and member paths of both lists and callsvalidate_name_members. That new function incrates/core/src/validation/mod.rsholds the body ofvalidate_name_memberand loops over several members.validate_name_membercalls it with one member, so its callers keep their answers. The bounds of an index name, 3 to 255, are now the constantINDEX_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_LIMITincrates/core/src/validation/mod.rs. The PartiQL request checks list at most 10 clauses, with the limitMAX_PARTS, which is private tocrates/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_FAULTSincrates/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 incrates/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.nislocalSecondaryIndexOverride.n.member.indexNameandG.nisglobalSecondaryIndexOverride.n.member.indexName. LEN isMember must have length greater than or equal to 3, and PAT is the pattern clause.abg iabg i, with the LSI list first in the bodyg iabababab,g iab,g iab,cdg ia!g ig iaba!a!a!g ig i10 validation errors detected:, L.1 PAT to L.10 PAT (3 December 2026)g ig ia!10 validation errors detected:, G.1 to G.5, each LEN and PAT (3 December 2026)g ig i10 validation errors detected:, L.1 to L.3 PAT, then G.1 to G.7 PAT (3 December 2026)g i, thena!11 validation errors detected:, G.1 to G.9 PAT, then G.10 LEN and PAT (3 December 2026)a!g i11 validation errors detected:, L.1 to L.9 PAT, then G.1 LEN and PAT (3 December 2026)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 -- --checkis clean.cargo +1.97.0 clippy -p extenddb-core -p extenddb-engine --all-targets -- -D warningsis 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-targetsis clean.cargo +1.97.0 test -p extenddb-wasm-adapter: the 3 unit tests and the parity test pass.the_index_name_faults_of_both_override_lists_are_answered_togetherhas 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 sixa!, 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 thetruncateof ad80b47 in place of the new check, the test fails at the row of nineg ianda!. 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.CLAUSE_LIMIT. Against ExtendDB on SQLite and on PostgreSQL,tests/test_backup_restore_fidelity.pypassed its 37 tests on each backend. One of them readsEXTENDDB_TEST_BACKUP_STOREand passed in a second run with it set tonone. The table of restore names now has 17 measured rows. Against a SQLite server built with thetruncateof ad80b47,test_backup_and_table_names_are_validatedfails 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 -qcollects 7301 tests intests/and 820 intests/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 5backup_store::testsfail 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 checkof the four crates with--all-targetsis 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.tests/test_backup_restore_fidelity.py37,tests/test_continuous_backups.py9,tests/test_authz_cross_account.py19,tests/test_authz_resource_arn.py49,tests/python/test_nul_table_name_fields.py52,tests/python/test_nul_arn_shapes.py48 andtests/python/test_warm_throughput_backup.py1. The 46 tests oftests/test_backup_job.pyskipped, because they start their own server fromEXTENDDB_BINARYand 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 -qcollects 7301 tests intests/and 820 intests/python, with no error.tests/test_backup_restore_fidelity.pygets 13 rows from the measurements. Against a server built from8022210a8, 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.validate_name_memberandvalidate_index_namegave the same answer as on8022210a8, for 20 requests. The callers are CreateTable, UpdateTable, CreateBackup, ListBackups, both ContinuousBackups operations and both restores. That revision differs fromd7717df88only in the tests and in the place of oneuseline.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 ofvalidate_name_members. When the second of the two PRs merges, thevalue.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 incrates/engine/src/backup/overrides.rsas 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 ofvalidate_name_membertoo: it addsvalidate_name_member_after, which lists the clauses of other members first. The PR that merges second takes both changes and combinesvalidate_name_membersandvalidate_name_member_afterinto one helper. #1284, #1291 and #1327 merge cleanly with this head. This PR adds no conflict withmain.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 RestoreTableFromBackup with bad
IndexNamevalues 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.