Repository navigation
fix(memory): local index reads fetch what the index does not hold - #108
Merged
kalaspuff merged 4 commits intoOct 30, 2026
Merged
Conversation
The in-memory DynamoDB answered a read of a local index with a projection from the index entries alone, so attributes the index does not hold were missing: a KEYS_ONLY index queried with ProjectionExpression "secret, lsk" returned only lsk, and model reads with .project(...) lost the fields the index leaves out. PartiQL SELECTs of such attributes did the same. Reads that did fetch the items (Select=ALL_ATTRIBUTES, which model reads of partial local indexes send) counted only the entries towards the 1 MB of a page and the read units, so ten items of 300 KB came back in one page for one read unit. DynamoDB fetches the table item of each entry when a read of a local index returns an attribute the index does not hold, counts the entries (rounded up to 4 KB) and each fetched item (rounded up to 4 KB on its own) towards the page, and charges a read of each fetched item to the table besides the read of the entries on the index (the Query API reference and the local secondary index guide). Query, Scan and PartiQL SELECT now do that; the WHERE clause of a SELECT still reads the index entries. Refs #73 Co-authored-by: Carl Oscar Aaro <[email protected]>
…com-kalaspuff-dynamoxy-issu # Conflicts: # CHANGELOG.md
…com-kalaspuff-dynamoxy-issu Brings in #104 (PartiQL transactions that name an item twice are refused). CHANGELOG.md conflicted where both added an entry at the end of [Unreleased] Fixed: both entries are kept, #104's first. Co-authored-by: Carl Oscar Aaro <[email protected]>
…com-kalaspuff-dynamoxy-issu Brings in #103 (list elements set past the end append in order of their index). CHANGELOG.md conflicted where both added an entry at the end of [Unreleased] Fixed: both entries are kept, #103's first. Co-authored-by: Carl Oscar Aaro <[email protected]>
kalaspuff
deleted the
fctl/52-https-github-com-kalaspuff-dynamoxy-issu
branch
October 30, 2026 23:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
The in-memory DynamoDB answered a read of a local secondary index from the index entries alone when a projection named attributes the index does not hold, where DynamoDB fetches each item from the table: a
KEYS_ONLYindex queried withProjectionExpression="secret, lsk"returned onlylsk,client.model(Note).query(index="by_kind", owner="ada").project("body", "kind")returned[{"kind": "todo"}], and PartiQLSELECTs did the same. Reads that did fetch the items (Select=ALL_ATTRIBUTES, which model reads of partial local indexes always send, ADR 0012) counted only the entries towards the 1 MB of a page and the read units, so ten 300 KB items came back in one page for 1 read unit.Query,Scanand PartiQLSELECTof a local index now fetch each item they evaluate from the table whenever they return an attribute the index does not hold. Such a page stops at 1 MB of the entries (rounded up to 4 KB) plus each fetched item (rounded up to 4 KB on its own), and is charged a read of each fetched item on the table besides the read of the entries on the index, as the Query API reference and the local secondary index guide describe. TheWHEREclause of aSELECTstill reads the index entries.Verified with new memory backend tests of projections, scans, page sizes, read units and PartiQL, which fail without the fix, an integration test of
.project(...)of a local index, andmake check. MiniStack never reads the table for local indexes, so the integration test checks the fetch on the memory backend only, like the existing test ofSelect=ALL_ATTRIBUTES.Checklist
make checkpasses locally (lint, types, clippy, consistency, Rust and Python tests)Worth confirming
SELECTs of a local index fetch too, although the issue names onlyQueryandScan; theirWHEREclause keeps reading the index entries, as dynoxide-rs measured against DynamoDB.FilterExpressionof aQueryorScanthat fetches evaluates the table item, asSelect=ALL_ATTRIBUTESreads already did, so a filter on an attribute the index does not hold now matches when the projection fetches. The evidence collected in Filters and projections of attributes an index does not project: DynamoDB rejects some that dynamoxy accepts #106 suggests DynamoDB rejects such filters in queries; that question is left to Filters and projections of attributes an index does not project: DynamoDB rejects some that dynamoxy accepts #106.Fixes #73
fctl session
Note
Medium risk. It changes what the in-memory DynamoDB returns, how big its pages are and what read units it reports for local index reads, which tests of applications that use the memory backend may rely on; the AWS adapter and stored data are untouched.
What it does. Makes the in-memory backend read a local secondary index the way DynamoDB does: when a
Query,Scanor PartiQLSELECTreturns an attribute the index does not hold, each item is fetched from the table, so the result is complete instead of missing those attributes. Such a page now counts each fetched item (rounded up to 4 KB) towards the 1 MB limit and charges a read of each item to the table besides the read of the index entries. A newPageReadhelper intable.rscarries this accounting for all three operations, and new memory backend tests and an integration test cover it.Filter semantics. A
FilterExpressionof a fetchingQueryorScannow evaluates the table item, so a filter on an attribute the index does not hold matches when the projection fetches; the description leaves open whether DynamoDB rejects such filters (#106).fctl review's first look at
e3bc3eb· 7 files, +237 −29 · Review agent settings