Skip to content

fix(core): name the capacity member and value when it is below 1 - #1442

Open
eliseong wants to merge 6 commits into
mainfrom
eliseong-capacity-below-1-message-2026-11-24
Open

eliseong wants to merge 6 commits into
mainfrom
eliseong-capacity-below-1-message-2026-11-24

Conversation

@eliseong

@eliseong eliseong commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

What

On a PROVISIONED table, a ReadCapacityUnits or WriteCapacityUnits below 1 is now refused with the service's text: one constraint clause for each member below 1, naming the member's request path and the value sent, writeCapacityUnits before readCapacityUnits, counted in the lead sentence (N validation error(s) detected: ...).

  • CreateTable with a table ProvisionedThroughput names the members of every global secondary index and of the table in one message, the indexes in position order first, as globalSecondaryIndexes.<n>.member.provisionedThroughput.<member> and provisionedThroughput.<member>. It names and counts at most 10, as the service does.
  • UpdateTable names the table's members.
  • RestoreTableFromBackup names a ProvisionedThroughputOverride member as provisionedThroughputOverride.<member>.

The clauses go to one call of extenddb_core::error::validation_errors. UpdateTable's index Create keeps its existing text. The upgrade manual lists the change under v1.2.0.

Why

ExtendDB answered these requests with one sentence of its own. The service names each member and the value.

Closes #1147

Testing done

  • DynamoDB in us-east-1 on 2 December 2026, each request sent twice with the same answer both times:
    • CreateTable: table {0, 5} with gsi1 {5, 0}; table {1, 1} with gsi1 {0, 5} and gsi2 {5, 0}; table {1, 1} with gsi1 {0, 0} and gsi2 {0, 7}; table {0, 1} with gsi1 {1, 1} and gsi2 {0, 7}; table {0, 0} with gsi1 {0, 0}; table {1, 1} with a third GSI at {0, -1}; 20 GSIs at {0, 0}; 21 GSIs at {0, 1} with table {0, 1}.
    • RestoreTableFromBackup with ProvisionedThroughputOverride {0, 5}, {5, 0} and {0, 0}, on a BackupArn that does not exist.
    • A SQLite server built from this branch gives the service's text for each. main gives it for none.
  • Unit tests pin these texts as literals, with a request id for each, and the four rows of CreateTable refuses a capacity figure below 1 with its own sentence, where DynamoDB names the member and the value #1147 on the CreateTable path.
  • tests/test_table_operations.py::test_update_table_zero_throughput asserts the UpdateTable text end to end; it fails on main.
  • cargo test -p extenddb-core --lib (1265 passed) and cargo test -p extenddb-engine --lib (985 passed). cargo fmt --all -- --check is clean. cargo clippy -p extenddb-core -p extenddb-engine --all-targets -- -D warnings is clean apart from the unused line_len in crates/core/tests/data_file_decode_peak.rs on macOS, which main has too.

Notes

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

None. The error type and the HTTP status do not change. The new texts are listed in the upgrade manual under v1.2.0.


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.

CreateTable and UpdateTable refused a ReadCapacityUnits or WriteCapacityUnits
below 1 with one sentence of ExtendDB's own. DynamoDB writes a constraint
clause for each member below 1, with the member's request path and the value
sent, WriteCapacityUnits first, counted in the lead sentence.

A shared helper now builds that answer, and the table throughput of CreateTable,
the global secondary index throughput of CreateTable, and the table throughput
of UpdateTable use it. The index path names the index position, as the service
does. The differences doc records the measured CreateTable form.

RestoreTableFromBackup reaches the same table and index checks, so its override
answers change with them; the exact restore paths stay #1097's. UpdateTable's
GSI Create path was not measured and keeps its older text.

Also gate the data_file_decode_peak test's line_len binding to Linux, where it
is read, so clippy is clean off Linux. This is unrelated to the capacity fix.

Refs #1147

@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 72ab651. 1 finding: 1 Important.

The change replaces the below-1 capacity message with per-member clauses for CreateTable table and GSI throughput and for UpdateTable table throughput. Confirmed against the live service and the SQLite backend: a single bad table member, both table members (writeCapacityUnits first), a table member of i64::MIN, and UpdateTable with 0/0, 0/5, 5/-1 and with BillingMode PROVISIONED or PAY_PER_REQUEST all return the same text on both. A single bad GSI also matches. cargo test -p extenddb-core -p extenddb-engine passed under 1.91.1.

  • Important crates/core/src/validation/mod.rs:260 — CreateTable still stops at the first bad GSI and checks the table throughput first, so a request with several below-1 members gets fewer clauses and a smaller count than the service returns.

Comment thread crates/core/src/validation/mod.rs Outdated
for (i, gsi) in input.global_secondary_indexes.iter().flatten().enumerate() {
if let Some(t) = gsi.provisioned_throughput.as_ref()
&& let Some(e) = validation_below_minimum_for_index(i + 1, t)
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Important
The description says the message counts one clause per member below 1, but validate_gsi_throughput_minimum returns at the first bad GSI (validation/mod.rs:260-265), and validate_create_table returns the table's error at :120 before the GSI check at :122, so the clauses are never combined. The live service collects every below-1 member of the request into one message, GSIs in position order first, then the table. A client that parses the count or the paths sees a different message from the service, and nothing in logs or metrics shows the difference.

Fix: gather the clauses from every GSI (positions 1..n) and then from the table in validate_create_table, and build one N validation error(s) detected: ... message from them; the tests at validation/mod.rs:3365-3457 and backup/tests.rs:5451-5461 cover single-surface cases only and need an added multi-surface case. Alternatively state in the PR body and docs/differences-from-dynamodb.md:113 that multiple surfaces are reported one at a time. No migration.

Evidence: sent the same CreateTable to the live service and to the SQLite harness server (client validation off). Table 1/1, GSI1 0/0, GSI2 0/7: service 3 validation errors detected: with GSI1 write, GSI1 read and globalSecondaryIndexes.2.member.provisionedThroughput.readCapacityUnits; head 2 validation errors detected: with GSI1 only. Table 0/1, GSI1 1/1, GSI2 0/7: service 2 validation errors detected: (globalSecondaryIndexes.2...readCapacityUnits then provisionedThroughput.readCapacityUnits); head 1 validation error detected: with the table clause only. Table 0/0 plus GSI1 0/0: service 4 errors (GSI clauses, then table); head 2 (table only).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 52cf343 and b7aa533. CreateTable now names the capacity figures below 1 of every GSI and of the table in one message, the GSIs in position order first, and at most 10, as the service does. Your three requests and the ones measured on 2 December give the service's text, and a unit test pins each of them as a literal.

When the table has no ProvisionedThroughput, or the key schema or attribute definitions have a fault too, ExtendDB still answers that check first, where the service names the throughput members. The PR body lists this.

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

Thanks. I read the change against main 92155f3. The CreateTable and UpdateTable table texts and the write-first order match #1147's rows and my comment of 21 November there. The check stays where it was, ahead of any storage read. On this branch the core validation tests (228), the engine update_table tests (11) and the engine backup tests (467) passed. Against servers built from this branch and from main, tests/test_table_operations.py passed 26 here, with 1 skip. On main only test_update_table_zero_throughput failed, at the text this PR sets. CI passed, and the branch merges with main.

LJMart11's comment on line 260 still stands. I measured it again in us-east-1 on 2 December, each request twice:

CreateTable throughput DynamoDB
table {0, 5}, gsi1 {5, 0} "2 validation errors detected: Value '0' at 'globalSecondaryIndexes.1.member.provisionedThroughput.writeCapacityUnits' failed to satisfy constraint: ...; Value '0' at 'provisionedThroughput.readCapacityUnits' failed to satisfy constraint: ..."
table {1, 1}, gsi1 {0, 5}, gsi2 {5, 0} "2 validation errors detected: Value '0' at 'globalSecondaryIndexes.1.member.provisionedThroughput.readCapacityUnits' failed to satisfy constraint: ...; Value '0' at 'globalSecondaryIndexes.2.member.provisionedThroughput.writeCapacityUnits' failed to satisfy constraint: ..."

This PR answers one clause for each request.

This overlaps #1096 (opened 17 November), which builds the same clause for the restore override with extenddb_core::error::validation_errors, the helper that #1147 names. Under code-size.md, the second of the two PRs to merge drops its copy. The two conflict in one hunk of crates/engine/src/backup/tests.rs, and so do #1353, #1365 and #1373, which build on #1096.

This needs three changes before it merges:

  1. provisioned_below_minimum_error builds by hand the envelope and the clause that validation_errors in crates/core/src/error/messages.rs already builds. If the table and every GSI add their clauses to one call of it, the count is also the service's.
  2. The restore override tests now pin texts that the service does not send. The inline comments on backup/tests.rs have the measured paths.
  3. 1.1.0 answered other texts for capacity below 1 on CreateTable, on its GSIs and on UpdateTable. docs/versioning.md puts such changes under Behavior Changes by Release in the upgrade manual, so this needs a v1.2.0: entry.

On the description: it says "Refs #1147", so a merge leaves #1147 open, although the PR covers all four of its rows. The inline comments are smaller.

Comment thread crates/engine/src/backup/tests.rs Outdated
(read, "readCapacityUnits")
};
let expected = format!(
"1 validation error detected: Value '{value}' at 'provisionedThroughput.{unit}' \

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 service names this member provisionedThroughputOverride.{unit} (#1096's measured rows of 13 and 14 November), so this test now pins a text that DynamoDB does not send. provisioned_below_minimum_error already takes a prefix, so validate_override_shape can pass provisionedThroughputOverride. Or this test can stay as main has it, and #1096 sets the restore text.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in 52cf343. validate_override_shape passes provisionedThroughputOverride, and the test pins the service's texts for {0, 5}, {5, 0} and {0, 0}, measured on 2 December with a BackupArn that does not exist, each request twice. These are the texts #1096 sets; the PR body gives the merge plan.

Comment thread crates/engine/src/backup/tests.rs Outdated
"{0, 0}",
json!({ "GlobalSecondaryIndexOverride": [gsi_entry(Some((0, 0)))] }),
"ReadCapacityUnits and WriteCapacityUnits must both be greater than or equal to 1",
"2 validation errors detected: Value '0' at 'globalSecondaryIndexes.1.member.provisionedThroughput.writeCapacityUnits' failed to satisfy constraint: Member must have value greater than or equal to 1; Value '0' at 'globalSecondaryIndexes.1.member.provisionedThroughput.readCapacityUnits' failed to satisfy constraint: Member must have value greater than or equal to 1",

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.

For a GSI override below 1, DynamoDB answers 2 validation errors detected: Value '0' at 'globalSecondaryIndexOverride.1.member.provisionedThroughput.writeCapacityUnits' ...; Value '0' at 'globalSecondaryIndexOverride.1.member.provisionedThroughput.readCapacityUnits' ..., before it reads the backup. I measured it on 2 December with a backup ARN that does not exist, each request twice. This line pins globalSecondaryIndexes.1.member....

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This row now pins only the constraint. ExtendDB checks the index throughput on the restored definition, after it reads the backup, so it cannot name globalSecondaryIndexOverride.<n>.member yet. #1097 tracks that, and the test comment names it.

/// `"globalSecondaryIndexes.<n>.member.provisionedThroughput"`. The service
/// writes one constraint clause per member below 1, `writeCapacityUnits`
/// first, and counts them in the lead sentence.
pub fn provisioned_below_minimum_error(

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.

See the review body: extenddb_core::error::validation_errors builds this envelope and clause. With one list of faults for the table and every GSI, this function becomes a short wrapper, and #1096 can call it with provisionedThroughputOverride.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in 52cf343. The table and every GSI add their faults to one list, and one call of validation_errors builds the message. provisioned_below_minimum_error is a short wrapper over the same helpers, and #1096 can call it with provisionedThroughputOverride.

encoder.write_all(&line).unwrap();
encoder.finish().unwrap()
};
#[cfg(target_os = "linux")]

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 gate is right, but it is not about the capacity message. A one-line PR of its own would keep this PR to #1147 (code-size.md rule 1).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed from this PR in 52cf343.

CreateTable stopped at the table's throughput, or at the first global
secondary index with a figure below 1, so a request with several such
members got fewer clauses and a smaller count than DynamoDB returns.
The service names every member below 1 of every index and of the table
in one message, the indexes in position order first (us-east-1,
2026-12-02, each request sent twice). The clauses now go to one call
of validation_errors.

RestoreTableFromBackup names a ProvisionedThroughputOverride member as
provisionedThroughputOverride.<member>, as the service does. The test
of a GlobalSecondaryIndexOverride below 1 pins only the constraint: the
service names globalSecondaryIndexOverride.<n>.member, which ExtendDB
does not yet do.

The upgrade manual lists the new texts under v1.2.0. The macOS gate in
data_file_decode_peak.rs goes back to main's form.

Refs #1147

Signed-off-by: Elise Ong <eliseong@amazon.com>
With more than 10 capacity figures below 1, DynamoDB names and counts
the first 10 (us-east-1, 2026-12-02, 20 and 21 indexes). The message
now does the same.

The tests pin the measured texts as literals, with a request id for
each, and pin the four rows of #1147 on the CreateTable path. The
upgrade manual entry and the differences row name the surfaces this
changes and the ones it does not: UpdateTable's GSI Create keeps its
text, and a GlobalSecondaryIndexOverride on a restore whose table is
PROVISIONED gets the CreateTable text.

Signed-off-by: Elise Ong <eliseong@amazon.com>
LeeroyHannigan
LeeroyHannigan previously approved these changes Dec 2, 2026

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

Approve. The three round 1 conditions are met.

  • One validation_errors call now names every capacity figure below 1. On CreateTable it lists the GSIs in position order, then the table.
  • The restore override names provisionedThroughputOverride.<member>.
  • There is a v1.2.0: upgrade entry.

The push also adds a cap: the message names and counts the first 10 figures. I measured that on DynamoDB in us-east-1, six requests, each sent twice. With 10 to 42 figures below 1, the service never named more than 10. It chose the GSIs in position order, write before read, then the table. The new unit tests pin these measured strings as literals. I changed the fix in two ways to check the tests catch a regression. With the cap removed, at_most_ten_throughput_faults_are_named fails. With the table placed before the GSIs, every_throughput_below_one_is_named_in_one_message fails.

I built the branch at b7aa533 and ran the tests that cover the change. Core validation passed 230, engine UpdateTable 11, engine backup 467. fmt and clippy are clean.

Duplication and size. The restore override change duplicates #1096 (opened 17 November). #1096 rewrites the same validate_override_shape and builds the same provisionedThroughputOverride clause from validation_errors, with the same member order and text. #1096 came first and is the dedicated restore PR. Whichever of the two merges second drops its copy. The 10-figure cap repeats the MAX_PARTS limit in crates/engine/src/partiql/request_checks.rs, which caps the same kind of message at 10. One shared constant, with a comment on the measurement, would keep the two limits the same. Size is production +114 and -38, tests +306 and -11, docs +27 and -1.

The points below are not conditions for approval:

  • The description is out of date. It says the PR gates the data_file_decode_peak test, which the branch reverted. It says "Refs #1147" though it covers all four of that issue's rows. It says the restore paths are out of scope, but the table override now carries the service path.
  • The measured rows sit in two test functions that repeat their setup. One parametrized test over all the rows would remove the copy.

@eliseong

eliseong commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

The three changes are in 52cf343 and b7aa533. CreateTable names the figures below 1 of the table and every GSI with one call of validation_errors, at most 10. The restore override names provisionedThroughputOverride.<member>. The upgrade manual has a v1.2.0 entry. The description now says Closes #1147 and gives the merge plan with #1096: the second to merge drops its copy, and both give the same texts.

@eliseong
eliseong added this pull request to the merge queue Dec 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Dec 2, 2026
@eliseong

eliseong commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

@LeeroyHannigan The branch conflicted with main after #1403 added its own v1.2.0 entry to the upgrade manual. 04ea133 merges main and keeps both entries, #1403's first. No code changed since b7aa533, which you approved.

LeeroyHannigan
LeeroyHannigan previously approved these changes Dec 3, 2026

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

Approve again. 04ea133 only merges main at e8b5f10. Your own change is the same in all seven files against the new main, the upgrade entry included, so I checked only that merge.

CI passed at this head, 75 of 75, and the branch merges cleanly with main at c8e66fb. Main changed four of the same files after e8b5f10, and your change still applies to each of them unchanged.

The restore override change still duplicates #1096, which came first. Whichever of the two merges second drops its copy.

@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 ran this head on SQLite next to a build of main, with a test of my own that sends the below 1 capacity requests that the description lists and some more. On main every CreateTable, UpdateTable and restore override case gives the old single sentence. On this head each one names the member, the value and the request path. A table 0/5 with a GSI 5/0 names the GSI first and the table second. Eleven GSIs at 0/0 give "10 validation errors". A GSI with no throughput on a provisioned table is still accepted, as on main. The UpdateTable index Create keeps the old text, as the description says. On a real backup, a GlobalSecondaryIndexOverride at 0/0 now names globalSecondaryIndexes.1.member.provisionedThroughput, and main said "for index: gsi1". The wire test test_update_table_zero_throughput passes here and fails on main. I did not check any answer against the live service, so the expected strings rest on the measurements already in this thread.

Two small things in the description and the branch. The test counts say 1247 for core and 978 for engine. At this head I get 1264 passed for core and 980 for engine, because main was merged into the branch after those numbers were taken. Could you update them? The branch also conflicts with main in docs/manuals/07-upgrade-manual.md. With the PR side kept in that file, the merged tree passes the core and engine lib tests here (1265 and 985).

I will approve once the branch is merged with main and the test counts in the description match.

…ow-1-message-2026-11-24

# Conflicts:
#	docs/manuals/07-upgrade-manual.md

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

Approve again. 2c80beb only merges main at 1e2ebdd. Your own change is the same in all seven files against the new main, the upgrade entry included, so I checked only that merge.

CI passed at this head, 75 checks. One run of the PR title check was cancelled when a second run started, and the second run passed. The branch merges cleanly with main at 1e2ebdd.

The restore override change still duplicates #1096, which came first. Whichever of the two merges second drops its copy.

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.

CreateTable refuses a capacity figure below 1 with its own sentence, where DynamoDB names the member and the value

4 participants