Repository navigation
fix(engine): charge a batch UPDATE that refers to an absent attribute - #1217
LeeroyHannigan wants to merge 1 commit into
Conversation
In a BatchExecuteStatement, DynamoDB charges the write units of an UPDATE that fails because it refers to an attribute its item does not have. ExtendDB returned the same error but did not charge the UPDATE. DynamoDB gave the answers below in us-east-1 on 19 and 20 November 2026. Each request went out twice, with ReturnConsumedCapacity set to TOTAL. The table has the partition key pk and holds an item with a string s and no attribute z. SET a = 9 on another item, then SET a = z + s on that item, cost 2.0 units. ExtendDB answered 1.0 before this change. SET a = 9 alone cost 1.0 on DynamoDB and on ExtendDB. Neither returned ConsumedCapacity for SET a = z + s alone. This change adds the error text of an absent attribute to UPDATE_FAILURES, the list of update errors that is_charged_failure charges. The charge is the write units of the stored item. On 20 November, DynamoDB charged 3 units for this error on an item of 3 KB. Fixes #1178.
navareamol
left a comment
There was a problem hiding this comment.
The description says the evaluator writes the absent text "in three places" in crates/core/src/expression/update_evaluator.rs. I find it twice at this head and on main: line 137 (a SET value whose path has no value) and line 565 (a list index past the end in set_nested). Could you correct the count?
The new row in failures_at_the_item_are_charged builds its error from UPDATE_FAILURES[2], so it compares the list with itself. I changed the new entry's text in batch.rs and kept the array size: the engine lib tests still pass (978 of 978), and only the wire row absent-attribute fails. I think writing the literal text in the unit row would let the unit test catch a typo here, or a later change to the evaluator's text.
The charge is decided by the text alone, so every UPDATE that fails with the absent text is now charged. On SQLite with this branch merged with main, SET g = z on the GSI table (where g is the index key) is charged one unit (batch total 3.0, 2.0 on main), and so are SET a = z and SET a = list_append(z, [1]). The row index-key-type-is-not-charged shows DynamoDB does not charge SET g = 1. Has anyone measured whether DynamoDB charges SET g = z? If it does not, this case needs more than the text match; if it does, a row for it would pin that.
The branch merges with current main without conflict, and on the merged tree every row of the description's table reproduces on SQLite, including INDEXES and the 3 KB item. On main the new row fails with 2.0 where it expects 3.0.
I will approve once the count in the description is corrected and the SET g = z question is answered.
What
In a BatchExecuteStatement, ExtendDB did not charge an UPDATE that fails at its item with
The provided expression refers to an attribute that does not exist in the item. DynamoDB charges the write units of the stored item for this error. This change adds the text toUPDATE_FAILURESincrates/engine/src/partiql/batch.rs, the list of update errors thatis_charged_failurecharges.The new entry is a literal, as the two entries before it are. The evaluator writes the same text as a literal in three places in
crates/core/src/expression/update_evaluator.rs. A shared constant would change that file, which #1180 rewrites, so the copy stays.Why
DynamoDB's answers, measured in us-east-1 on 19 and 20 November 2026 with
"ReturnConsumedCapacity": "TOTAL"where the row does not name another value. Each request went out twice and got the same answer both times.pk(S) as its key. Its itemem-upd-operandholds a stringsand a listkof 2 elements, and no attributez.pkandsk(S) as its key and the GSIgsiwith anALLprojection, astests/partiql_gsi_table.pycreates it.SET a = 9onem-upd-okSET a = z + sonem-upd-operandSET a = z + sonem-upd-operandaloneConsumedCapacityConsumedCapacitySET a = 9onem-upd-ok, thenSET a = k[5]onem-upd-operandSET a = 9on one item, thenSET a = z + gson anotherINDEXESCapacityUnits3.0,Table1.0,gsi1.0Table1.0,gsi1.0SET a = 9on one item, thenSET a = z + gson an item of 3 KBWith this change, ExtendDB answers each row with DynamoDB's
ConsumedCapacity. AtINDEXES, the unit of the failed UPDATE goes toCapacityUnitsalone. DynamoDB cancels an ExecuteTransaction with the same statements and returns noConsumedCapacity. ExtendDB also cancels it with noConsumedCapacity, and this change does not touch that path.Fixes #1178
Testing done
cargo test -p extenddb-engine --lib: 870 passed.cargo test -p extenddb-core --lib: 1146 passed.cargo +1.97.0 clippy -p extenddb-engine --all-targets -- -D warningsandcargo +1.97.0 fmt --all -- --checkare clean.failures_at_the_item_are_chargedgets a row for the new entry.tests/test_partiql_batch.pypassed 171 tests,tests/test_partiql_requests.py68 andtests/test_partiql_transaction.py197, with 2 expected failures. The new rowabsent-attributeoftest_a_failed_write_is_charged_on_its_tablesends the first G request of the table. It fails on main's server, with 2.0 where it expects 3.0.Line counts: production +4 -2, tests +5.
Not in this PR:
SET a = s + z, withsa string andzabsent, answers the absent attribute text, where DynamoDB answers the operand type text #1034 (open PR fix(core): report the first failing operand of +, - and list_append #1180):SET a = s + zonem-upd-operandanswers the absent text, where DynamoDB answers the operand type text. With this change, its charge already matches.SET k[5].x = 1onem-upd-operandanswers the absent text, where DynamoDB answers the document path text. With this change, its charge matches.This PR adds no conflict with an open PR.
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.