Repository navigation
fix(query): requests of growing reads ask for at most a page's worth of items - #70
Merged
kalaspuff merged 3 commits intoOct 30, 2026
Merged
Conversation
Contributor
Author
|
Stack of 5 open pull requests (from a pass over the library for bugs; #61 to #65 are merged already), merged in this order with "Squash and merge":
The findings that are not fixed here are filed as issues (see the next comment on #72). |
3 of 4 tasks
This comment has been minimized.
This comment has been minimized.
…of items When dynamoxy's own filters (the entity type, guard items) or client checks (a templated sort key prefix that where() replaced) removed items from a page, the next request asked for four times as many, without a bound. After about 16 such pages in a row (16 MB of other entities in a shared table), the Limit no longer fit the request's unsigned 32-bit integer, and first(), exists(), limit() and iteration raised OverflowError. `limit(n)` with n above that raised it at once. Requests now ask for at most 1,048,576 items, more than a 1 MB page can hold, so the page size bounds them as before. Co-authored-by: Carl Oscar Aaro <[email protected]>
kalaspuff
force-pushed
the
fixes-stack/09-bounded-limits
branch
from
October 30, 2026 21:40
e4ce09d to
7e5e463
Compare
…orth too The bound of the request Limit only applied while growing reads iterated: `query.limit(2**33).page()` and `page_size(2**33)` still sent a Limit that the request cannot hold and raised OverflowError. The bound now applies where every request is built. Co-authored-by: Carl Oscar Aaro <[email protected]>
This was referenced Oct 30, 2026
Closed
Closed
Closed
Table updates: provisioned billing without index throughput, and calls while a table is changing
#87
Closed
This was referenced Oct 30, 2026
Closed
Closed
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
Since 0.3.0, a read with a limit asks DynamoDB for only as many items as it still needs. When dynamoxy's own filters remove items from a page, the next request asks for four times as many, so that a few requests find what the limit wants. Those filters are the entity type of single-table models and the guard items of unique models, plus the client check of a templated sort key prefix that
where()replaced. The growth had no bound: after about 16 such pages in a row, the request'sLimitno longer fit DynamoDB's (and the binding's) unsigned 32-bit integer, and the read raisedOverflowError: number too large to fit in target type.The review that found it reproduced it with 12,000 customers of about 1 KB and no orders in a shared table:
client.model(Order).scan().exists()raisedOverflowErrorafter 17 requests asking for 1, 4, 16, … 4,294,967,296 items.first(),exists(),limit(n)and the iteration of such reads were affected, and so waslimit(n)with anynabove 2³².Every request now asks for at most 1,048,576 items: growing reads,
page(), and alimit()orpage_size()above that. That is more than a 1 MB page can hold, so the 1 MB page size bounds them as before, and the reads still need only a few requests.Verified with a new integration test on the in-memory backend and MiniStack. It raises the growth factor, so that the second request already exceeds 2³², and reads with
limit(2**33)andpage_size(2**33)throughpage()and iteration: before the fix both backends raisedOverflowError. Also with the whole suite, ruff, pyrefly and the consistency checks.Checklist
make checkpasses locally (lint, types, consistency, tests; no Rust change)fctl session
Note
Low risk. It only caps the
Limitthat query and scan requests send, in one Python module, and the cap is above what a 1 MB page can hold, so results are unchanged.What it does. Reads with a limit grew the
Limitof their next request fourfold whenever dynamoxy's own filters (entity type, unique guards, the client check of a templated sort key prefix) removed items from a page. The growth had no bound, so after about 16 such pages the number no longer fit an unsigned 32-bit integer and the read raisedOverflowError. Every request now asks for at most 1,048,576 items, applied where the request parameters are built, so growing reads,page(), and alimit()orpage_size()above that bound are all covered. A new integration test covers it on the in-memory backend and MiniStack, and the changelog gets an entry.fctl review's first look at
125f537· 3 files, +51 −3 · Review agent settings