Repository navigation
fix(mongodb): find never reads an unbounded result; .limit(0) is capped and says so (#1357) - #1696
Merged
Merged
Conversation
…ed and the summary says so (#1357)
2 tasks
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.
Refs #1357 (the default cap and the capped note; reading in chunks is not done).
MongoService.findapplied a limit only when it was positive and then didstream.toList(). Every screen already passes one (the MQL default is 100, the document pager its page size, the editor andfindOne1, MCP its row cap), so the open paths were the API default and an explicit.limit(0), which MongoDB reads as "no limit":db.orders.find({}).limit(0)decoded the whole collection on the UI isolate (about 64 us per document, so 50,000 documents are a three-second wait).effectiveMongoFindLimit(limit):null,0or a negative number becomekMongoDefaultFindLimit(1000). An explicit positive limit is kept as given..limit(0)reached the cap.Not done from the issue: streaming the cursor in chunks instead of
toList(). With the cap in placetoList()holds at most 1000 documents unless the caller asks for more on purpose; chunking would be worth it together with the columnar work in #1549.Tests: the limit mapping, and the summary text (ordinary find,
.limit(0)at the cap,.limit(0)below it).