Skip to content

fix(tables): provisioned billing gives global indexes capacity, and table steps wait for the one before - #143

Merged
kalaspuff merged 12 commits into
issues-stack/6-derived-updatesfrom
issues-stack/7-table-updates
Oct 31, 2026
Merged

kalaspuff merged 12 commits into
issues-stack/6-derived-updatesfrom
issues-stack/7-table-updates

Conversation

@fctl-sh

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

Copy link
Copy Markdown
Contributor

Summary

Two ways dynamoxy's table management sent DynamoDB requests it refuses or can't take yet:

  • table.update_settings(billing=Billing.provisioned(10, 5)) of an on-demand table sent capacity for the table only. DynamoDB needs capacity for every global index of a provisioned table, and Billing.provisioned says its capacity is also used for global indexes without their own. A switch from on-demand to provisioned billing now also sends an index update giving each global index the table's capacity. A switch between provisioned capacities still changes the table only.
  • ensure_tables(wait=False) with two missing indexes added the second while DynamoDB was still creating the first (DynamoDB takes one table update at a time), and so did a rerun after the 300-second waiter gave up during a long backfill. create_tables/ensure_tables(wait=False) with a TTL attribute called UpdateTimeToLive on a table that was still CREATING. Each step now waits for the one before it: a created table is waited for before Time to Live is enabled, an index still being created (by this call or an earlier one) before the next is added, and only the last step is not waited for. ensure_tables() now enables Time to Live before it adds indexes, so that Time to Live does not wait for their backfills.

The in-memory backend makes tables and indexes active at once, so the tests record the order of operations and waits (middleware plus a recorded wait_until_active), and the update the billing switch sends; they failed before the change. uv run pytest, ruff, pyrefly and the consistency checks pass, and the tables guide describes both.

This is the Python part of #87. The memory backend still accepts a switch to provisioned billing without index capacity, an index added to a provisioned table without capacity, and keeps index capacity after a switch back to on-demand: DynamoDB's answers to these are not captured anywhere I could check, and the sandbox has no AWS credentials.

Refs #87

Worth confirming

  • Decision: a switch to provisioned billing gives every global index the table's capacity, even indexes whose model declares capacity of its own (update_settings() works on a table, which does not know its models). Indexes that need other capacity have to be changed afterwards.
  • Assumption: DynamoDB accepts the table's capacity and the index capacity updates in one UpdateTable request when it switches billing modes, as the console does; this was not verified against DynamoDB.
  • Decision: with wait=False, ensure_tables() still waits for each index before adding the next one, which for a large table can take a long time, rather than adding one index per call.

fctl session


Note

Medium risk. It changes the requests that table management sends to DynamoDB (billing switches, index creation order, Time to Live timing), which can't be checked against real DynamoDB here, though only for table setup and not for item reads or writes.

What it does. A switch from on-demand to provisioned billing in Table.update_settings now also gives every global index the table's capacity, as DynamoDB requires. ensure_tables and create_tables with wait=False now wait for the step before: a created table before Time to Live is enabled, and an index still being created (by this call or an earlier one) before the next one is added. ensure_tables also enables Time to Live before it adds indexes, so that it doesn't wait for their backfills. The newest commit documents that a table with a TTL attribute is waited for whatever wait says, and adds a test for reruns that start from a table or index still being updated.

Unverified DynamoDB behavior. That DynamoDB accepts the table's capacity and the index capacity updates in one UpdateTable request was not checked against DynamoDB, and the billing switch overwrites capacity that a model declares for an index.

fctl review's first look at 6e3c136 · 5 files, +155 −9 · Review agent settings

fctl-sh Bot and others added 11 commits October 31, 2026 04:44
…es not declare

Writes of loaded instances kept the item's undeclared top-level
attributes (ADR 0014), but a document decoded from a map held its
declared fields only, so saves by an older version of an application
erased keys a newer one added to documents (address.zip_code). A
document read from a map now remembers the keys no field declares and
writes them back whenever it is encoded; a document the application
builds replaces the map (ADR 0020).

Refs #99

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

dynamoxy checked values given outside an instance (key values of
lookups, values update() sets) with FieldSpec.validate, which for
pydantic models is the codec's type check: normalized keys found
nothing, and updates wrote values Field constraints refuse. Pydantic has
no public one-field validation, so each field gets a validator built
from its schema in the model's core schema (with its definitions and
the model's config), without validators that take a ValidationInfo
(they may read other fields) and without model validators.

Fixes #107

Co-authored-by: Carl Oscar Aaro <[email protected]>
…em, and require it unchanged

An instance that was not loaded, used as an update target, had its own
values taken for the stored ones when an update rendered derived
attributes, and updates by key (or of loaded instances without a
version) required no condition that the fields they rendered from were
unchanged, so a concurrent write left the derived attribute behind.
Such updates now read the item, require the fields they took from it
unchanged, and update() plans them again from the item as stored now
when another writer changed them.

Refs #84

Co-authored-by: Carl Oscar Aaro <[email protected]>
…able steps wait for the one before

update_settings(billing=Billing.provisioned(...)) of an on-demand table
sent capacity for the table only, although DynamoDB needs it for every
global index. ensure_tables(wait=False) added a second index while the
first was still being created, also after an earlier call's waiter gave
up during a backfill, and create_from(wait=False) enabled Time to Live
on a table that was still being created. Each step now waits for the
one before it, and Time to Live is enabled before indexes are added.

Refs #87

Co-authored-by: Carl Oscar Aaro <[email protected]>
…able steps wait for the one before

update_settings(billing=Billing.provisioned(...)) of an on-demand table
sent capacity for the table only, although DynamoDB needs it for every
global index. ensure_tables(wait=False) added a second index while the
first was still being created, also after an earlier call's waiter gave
up during a backfill, and create_from(wait=False) enabled Time to Live
on a table that was still being created. Each step now waits for the
one before it, and Time to Live is enabled before indexes are added.

Refs #87

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

This comment has been minimized.

Comment thread python/dynamoxy/table.py Resolved
…, and wait docs name Time to Live

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

fctl-sh Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

On the wait docs: fixed in 6e3c136. The wait argument of Table.create and Client.create_tables now says that a table with a TTL attribute is waited for anyway, since DynamoDB enables Time to Live on active tables only.

@fctl-sh

fctl-sh Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

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

  1. fix(memory): PartiQL index reads refuse attributes the index does not hold #137 fix(memory): PartiQL index reads refuse attributes the index does not hold
  2. fix(models): writes through loaded instances use keys stored in another form #138 fix(models): writes through loaded instances use keys stored in another form
  3. fix(models): repositories refuse instances of subclasses and items of other models #139 fix(models): repositories refuse instances of subclasses and items of other models
  4. fix(models): documents read from an item keep the keys their class does not declare #140 fix(models): documents read from an item keep the keys their class does not declare
  5. fix(pydantic): key values and update values run the field's pydantic validators #141 fix(pydantic): key values and update values run the field's pydantic validators
  6. fix(repository): updates render derived attributes from the stored item, and require it unchanged #142 fix(repository): updates render derived attributes from the stored item, and require it unchanged
  7. fix(tables): provisioned billing gives global indexes capacity, and table steps wait for the one before #143 fix(tables): provisioned billing gives global indexes capacity, and table steps wait for the one before ← this pull request

@kalaspuff
kalaspuff added this pull request to stack #144 October 31, 2026 05:44
@kalaspuff
kalaspuff merged commit eb0be68 into main Oct 31, 2026
22 checks passed
@kalaspuff
kalaspuff deleted the issues-stack/7-table-updates branch October 31, 2026 05:45
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.

1 participant