You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
In-memory DynamoDB: reads of a local index with a projection never fetch what the index does not hold #73
Priority: high. The in-memory backend returns fewer attributes, and smaller pages, than DynamoDB for reads of a local secondary index, so tests pass or fail differently from production.
What happens
With ProjectionExpression (Select=SPECIFIC_ATTRIBUTES), only the index entry is projected (backend/memory/query.rs, the evaluated match in page(); scans share it). Only ALL_ATTRIBUTES reads the table item. A KEYS_ONLY LSI lsi (pk, lsk) holding {pk: "a", sk: 1, lsk: 5, secret: "s"}, queried with ProjectionExpression="secret, lsk", returns [{"lsk": 5}]. Through models: client.model(Note).query(index="by_kind", owner="ada").project("body", "kind").all() returns [{"kind": "todo"}].
When it does fetch (ALL_ATTRIBUTES), the 1 MB page limit and the consumed capacity count only the index entry (query.rs, around the size and capacity accounting). Ten 300 KB items in a KEYS_ONLY LSI, read with Select=ALL_ATTRIBUTES and a consistent read, come back in one page of about 3 MB with 1.0 RCU; the same query on the table returns 4 items, a LastEvaluatedKey and 301 RCU. Model reads of partial local indexes always send ALL_ATTRIBUTES (ADR 0012), so they get this paging and capacity.
DynamoDB: the Query API reference says of SPECIFIC_ATTRIBUTES: "If any of the requested attributes are not projected into the local secondary index, DynamoDB fetches each of these attributes from the parent table." The LSI guide adds that the result size counts each fetched table item rounded up to 4 KB, and that reads are "charged for read capacity units for every base table item fetched". docs/guides/modeling.md promises the same.
Fix: for LSI reads, fetch the table item whenever the requested attributes are not all projected, and count the fetched items towards the page size and the read units.
Found in a review of the library for bugs (fctl session); the fixes that fit in its ten pull requests are #61 to #65, #67 to #70 and #72.
Activity