Skip to content

fix(tables): the in-memory backend refuses table changes DynamoDB refuses - #149

Merged
kalaspuff merged 35 commits into
mainfrom
parity-stack/3-table-updates
Oct 31, 2026
Merged

kalaspuff merged 35 commits into
mainfrom
parity-stack/3-table-updates

Conversation

@fctl-sh

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

Copy link
Copy Markdown
Contributor

Summary

The in-memory backend accepted table changes that DynamoDB refuses, so tests could not show the problems #87 describes. Measured in eu-north-1 (docs/parity), DynamoDB refuses a switch to provisioned billing without capacity for each global index, an index added to a provisioned table without capacity, and index capacity on an on-demand table (each a ValidationException with its own message). It answers UpdateTimeToLive of a table it is still creating with ResourceNotFoundException and UpdateTable with ResourceInUseException, and refuses a second index while one is being created with LimitExceededException, also once the table reads ACTIVE again during the first one's backfill. The in-memory backend now does all of this with DynamoDB's messages, and drops the indexes' capacity on a switch back to on-demand (DynamoDB reports 0/0).

The in-memory backend still creates tables and indexes at once, but they read CREATING in the first DescribeTable after them and ACTIVE from the next on, as a caller polling until they are active sees them, so tests catch a change made without waiting; the client's waiter polls the in-memory backend without sleeping, so tests are as fast as before. table.add_index() without billing= now gives an index added to a provisioned table its definition's capacity or the table's, which DynamoDB requires (ensure_tables already did). The in-memory backend also refuses deleting an index while another is being created, as DynamoDB's message ("created or deleted simultaneously") says; that case was not measured.

Verified with make check, the Rust parity scenarios against MiniStack, new memory backend tests with DynamoDB's messages, and Python tests on both backends (the refusals on the memory backend only, since MiniStack and LocalStack make tables active at once and accept the billing changes).

Worth confirming

  • Decision: a table or index being created reads CREATING in the in-memory backend for one DescribeTable, not for a time. Code that calls UpdateTable or UpdateTimeToLive right after creating a table without waiting now fails in tests as it would against DynamoDB; reads and writes of its items are still accepted, since DynamoDB's answer to those was not measured.

Fixes #87

fctl session


Note

Medium risk. It changes how the in-memory test backend answers table and index changes, so tests of applications that change tables without waiting will start failing, and it touches add_index() and ensure_tables() in the Python API.

What it does. Makes the in-memory backend refuse table changes that DynamoDB refuses: changes to a table still being created, a second index added while one is backfilling, and index capacity that does not match the table's billing mode. A new table or global index now reads CREATING in the first DescribeTable and ACTIVE from the next, so tests catch a missing wait, and the client's waiter polls the in-memory backend without sleeping. add_index() without billing= gives an index on a provisioned table the table's capacity, and ensure_tables() waits for a table being created before it describes its Time to Live.

Stricter in-memory backend. Tests that call update_table, add_index or Time to Live changes right after create(wait=False), or add two indexes in a row with wait=False, now fail in the in-memory backend as they do on DynamoDB; refusing an index deletion during a backfill follows DynamoDB's message and was not measured.

fctl review's first look at dccbf8d · 11 files, +420 −15 · Review agent settings

fctl-sh Bot and others added 15 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]>
@fctl-review

This comment has been minimized.

Comment thread python/dynamoxy/table.py Resolved
…n during a backfill follows DynamoDB's message

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

This comment has been minimized.

Comment thread python/dynamoxy/table.py Resolved
…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]>
@fctl-review

This comment has been minimized.

@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 ← this pull request
  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
  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

…describes its Time to Live

DynamoDB refuses DescribeTimeToLive while it is creating a table
(measured through the library probe on AWS); the in-memory backend now
does too, and sync_with waits for the table first.

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

This comment has been minimized.

Comment thread docs/guides/tables.md Resolved
Comment thread docs/parity/README.md Resolved
@kalaspuff
kalaspuff added this pull request to stack #155 October 31, 2026 18:18
Base automatically changed from parity-stack/2-index-reads to main October 31, 2026 18:27
@kalaspuff
kalaspuff merged commit 1b33563 into main Oct 31, 2026
5 checks passed
@kalaspuff
kalaspuff deleted the parity-stack/3-table-updates branch October 31, 2026 18:28
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.

Table updates: provisioned billing without index throughput, and calls while a table is changing

1 participant