Skip to content

fix(limits): local index entries count toward the 400 KB of an item, and transactions keep to 4 MB - #152

Merged
kalaspuff merged 83 commits into
mainfrom
parity-stack/6-size-limits
Oct 31, 2026
Merged

kalaspuff merged 83 commits into
mainfrom
parity-stack/6-size-limits

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The in-memory backend accepted requests over DynamoDB's size limits. Measured in eu-north-1 (docs/parity), DynamoDB refuses an item that fits 400 KB alone but not together with its entries in the table's local indexes: a 190 KB item an ALL local index holds is taken, a 210 KB one refused with "Item size has exceeded the maximum allowed size" (PutItem) or "Item size to update has exceeded the maximum allowed size" (UpdateItem), and a transaction cancels with it as a ValidationError reason, since it depends on the table. A plain item over 400 KB stays a refusal of the whole request, as dynoxide-rs records. DynamoDB also refuses a TransactGetItems that would return more than 4 MB of items ("Payload in response is too large."), and a TransactWriteItems over 4 MB with "Transaction payload size cannot exceed 4MB. Payload Size: N", where N counts a put's item, an update's key, request charge and 8 bytes, a delete's and a check's key, and each one's condition (every condition form measured, each a constant on top of its operands); table and placeholder names count nothing (round 2 and dynamoxy's probe on AWS). The in-memory backend now does all of this: the five transactions of round 2 give DynamoDB's exact sizes. It also holds a standalone UpdateItem to 400 KB by its request charge before reading the item, which dynoxide-rs measured across 86 statements, and reports item collection sizes as whole gigabytes ([0.0, 1.0] for a small collection, as DynamoDB did in round 3) instead of the exact fraction.

Verified with make check and memory backend tests with DynamoDB's messages; MiniStack accepts all of these requests, so the Python tests do not assert them on it.

Fixes #93

fctl session


Note

Medium risk. It makes the in-memory test backend refuse writes it used to accept (items whose local index entries push them past 400 KB, transactions over 4 MB, updates with a large request charge), so existing tests that run on it may start failing; the AWS adapter is untouched.

What it does. Makes the in-memory DynamoDB backend count an item's entries in the table's local indexes toward the 400 KB item limit, and refuse a TransactGetItems that returns more than 4 MB. It counts the payload of a TransactWriteItems the way DynamoDB does, from the request: a put's item, an update's key plus a computed request charge, a delete's and a check's key, and every operation's condition. A standalone UpdateItem whose request charge alone exceeds 400 KB is refused, and item collection metrics report whole gigabytes ([0.0, 1.0] for a small collection).

Fitted charges. The update and condition charges in request_charge and condition_charge are constants fitted to probe runs on DynamoDB kept in docs/parity; the 4 MB limit itself is taken as 2^22 bytes without having been probed.

fctl review's first look at 0ff3235 · 14 files, +1099 −29 · Review agent settings

fctl-sh Bot and others added 24 commits October 31, 2026 13:38
Creates throwaway tables, asks the questions #87, #93, #97 and #106 leave
open, logs every answer (with account ids masked) and deletes the tables.

Co-authored-by: Carl Oscar Aaro <[email protected]>
…ndex does not hold

DynamoDB refuses a query filter on attributes an index does not hold,
for local indexes too and whatever the query returns, and a projection
of a global index naming them (measured in eu-north-1, docs/parity).
The in-memory backend now does the same with DynamoDB's messages, its
scan filters see the index entries, and model reads raise ValueError
before any request (ADR 0021).

Co-authored-by: Carl Oscar Aaro <[email protected]>
…be round

AWS CLI v1 base64-encodes the B values of JSON input itself, so the
base64 text written for v2 became 400 KB items; the generators now write
what the version in use sends as the intended bytes. Round 3 asks where
LocalStack and the tests disagree.

Co-authored-by: Carl Oscar Aaro <[email protected]>
…f fetched items are an assumption

Co-authored-by: Carl Oscar Aaro <[email protected]>
…uses

Measured in eu-north-1 (docs/parity): DynamoDB refuses a switch to
provisioned billing without capacity for each global index, an index
without capacity on a provisioned table, index capacity on an on-demand
table, changes to a table it is still creating, and a second index while
one is being created. The in-memory backend now does the same, drops
index capacity on a switch back to on-demand, and keeps new tables and
indexes CREATING until a DescribeTable sees them. table.add_index()
gives an index of a provisioned table the table's capacity.

Co-authored-by: Carl Oscar Aaro <[email protected]>
…n during a backfill follows DynamoDB's message

Co-authored-by: Carl Oscar Aaro <[email protected]>
…be, so a lone describe does not end it

add_index() without billing= describes the table, which ended CREATING
in the in-memory backend and hid the missing wait DynamoDB refuses. A
table or index being created now reads CREATING in the first
DescribeTable and ACTIVE from the next on, as a poller sees it; the
client's waiter polls the in-memory backend without sleeping.

Co-authored-by: Carl Oscar Aaro <[email protected]>
…ance never matches again

A counter started again at 1 on a put() of an instance that was not
loaded and on delete-and-create, so an instance loaded before passed its
version check again and overwrote both writes (#84). Versions are now
random tokens (Attr[str]), set on every write; transactions with an
idempotency token derive theirs from it, so a retry is the same request
(ADR 0022).

BREAKING CHANGE: version() fields must be declared Attr[str]
(Annotated[str | None, Version()] in pydantic models); stored numeric
versions are not read.

Co-authored-by: Carl Oscar Aaro <[email protected]>
…nd operands DynamoDB refuses

Measured in eu-north-1 (docs/parity): placeholders over 255 bytes or
with invalid characters, attribute names of 64 KB or more, and
attribute_type(a, b) with a path are refused, and a read-only
ExecuteTransaction of a missing table is canceled with reason
ResourceNotFound. Single-item writes put their expression errors and
refused attribute names in DynamoDB's request-validation envelope, as
dynoxide-rs captured.

Co-authored-by: Carl Oscar Aaro <[email protected]>
…and transactions keep to 4 MB

Measured in eu-north-1 (docs/parity): an item and its entries in local
indexes share the 400 KB limit (a transaction cancels with it as the
reason), a TransactGetItems may return at most 4 MB, and an oversized
TransactWriteItems has its own message. The in-memory backend now
refuses them like DynamoDB.

Co-authored-by: Carl Oscar Aaro <[email protected]>
@fctl-sh

fctl-sh Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

Stack of 8 pull requests, merged in this order with "Squash and merge":

  1. docs(parity): keep DynamoDB's measured answers and the probes that ask them #147 docs(parity): keep DynamoDB's measured answers and the probes that ask them (merged)
  2. fix(indexes): reads refuse filters and projections of attributes an index does not hold #148 fix(indexes): reads refuse filters and projections of attributes an index does not hold (merged)
  3. fix(tables): the in-memory backend refuses table changes DynamoDB refuses #149 fix(tables): the in-memory backend refuses table changes DynamoDB refuses
  4. fix(versions)!: version() fields hold a random token, so a stale instance never matches again #150 fix(versions)!: version() fields hold a random token, so a stale instance never matches again
  5. fix(expressions): the in-memory backend refuses placeholders, names and operands DynamoDB refuses #151 fix(expressions): the in-memory backend refuses placeholders, names and operands DynamoDB refuses
  6. fix(limits): local index entries count toward the 400 KB of an item, and transactions keep to 4 MB #152 fix(limits): local index entries count toward the 400 KB of an item, and transactions keep to 4 MB ← this pull request
  7. fix(errors): LocalStack's DuplicateItem code raises DuplicateItemError, and the e2e tests pass on LocalStack #153 fix(errors): LocalStack's DuplicateItem code raises DuplicateItemError, and the e2e tests pass on LocalStack
  8. test: probe dynamoxy itself on DynamoDB, MiniStack, LocalStack and the in-memory backend #154 test: probe dynamoxy itself on DynamoDB, MiniStack, LocalStack and the in-memory backend

@fctl-review

This comment has been minimized.

Comment thread crates/dynamoxy-core/src/expr/update.rs Resolved
Comment thread crates/dynamoxy-core/src/expr/update.rs Resolved
Comment thread crates/dynamoxy-core/src/expr/update.rs Resolved
fctl-sh Bot and others added 3 commits October 31, 2026 17:08
…ndition form tested, and the payload measurements in a table

Co-authored-by: Carl Oscar Aaro <[email protected]>
…ad as DynamoDB counts it

Measured one form at a time through the probe's third run on AWS: a
path in a condition counts as where it is read, and each form adds a
constant on top of its operands. All eighteen measured conditions and
every payload size of the runs now match exactly.

Co-authored-by: Carl Oscar Aaro <[email protected]>
@kalaspuff
kalaspuff added this pull request to stack #155 October 31, 2026 18:18
Base automatically changed from parity-stack/5-expressions to main October 31, 2026 18:32
@kalaspuff
kalaspuff merged commit 9c3cc19 into main Oct 31, 2026
20 checks passed
@kalaspuff
kalaspuff deleted the parity-stack/6-size-limits branch October 31, 2026 18:33
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.

In-memory DynamoDB accepts empty query keys, start keys outside the key condition, and oversized items

1 participant