Repository navigation
fix(grid): say when memory, not the row limit, cut the results short - #541
Merged
Merged
Conversation
Closes #413. Both reasons a result set can come back short set the same boolean, so the banner gave the same advice either way: Results truncated to 10,000 rows. Add a LIMIT clause to fetch fewer rows. When the memory guard was what stopped the fetch, that is wrong advice pointed at the wrong lever. Someone already running LIMIT 10000 reads it, concludes the limit is binding, and raises it — asking for more of the resource that had just run out. Nothing in the UI mentions memory. QueryResult now carries truncation_reason: Option<TruncationReason>, and rows_truncated is derived from it at the single place a truncated result is built, so the flag and the reason cannot drift apart. The banner text moves to truncationMessage, which names memory or the row limit, and says which lever actually helps: for memory, a narrower projection or a WHERE clause, explicitly not a larger LIMIT. An absent reason falls back to stating the row count and claiming nothing about why — a result from an older backend should not be guessed at. The derivation is now truncation_for, which prefers memory when both apply. In the streaming path the guard cannot in fact be the answer: tripping it breaks out of the fetch loop, so the statement-complete marker never arrives and that case is handled after the loop. The branch is kept anyway so both sites derive the reason identically and a change to the control flow cannot quietly restore the wrong advice. Verified: - five unit tests on truncation_for, including memory winning over a simultaneously-reached row limit - two integration tests against MySQL 8, asserting the reason survives the round trip: RowLimit when the limit is hit, None when it is not - four unit tests on truncationMessage, and two banner tests, both of which fail against the previous copy Not verified: the post-loop MemoryGuard block firing under real memory pressure. The guard's 512 MB floor is hardcoded and cannot be injected, so there is no way to provoke it in a test without starving the machine. Every piece it depends on is covered; the block itself is not. Follow-up filed. Co-Authored-By: Claude Opus 5 <[email protected]>
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.
Closes #413.
The bug
Both reasons a result set can come back short set the same boolean, so the banner gave the same advice either way:
When the memory guard stopped the fetch, that points at the wrong lever. Someone already running
LIMIT 10000reads it, concludes the limit is binding, and raises it — asking for more of the resource that had just run out. Nothing in the UI mentions memory at all.The fix
QueryResultcarriestruncation_reason: Option<TruncationReason>(row_limit|memory_guard), androws_truncatedis derived from it at the single place a truncated result is built, so the flag and the reason cannot drift apart.The banner text moves into
truncationMessage, which names the cause and the lever that actually helps — for memory, a narrower projection or a WHERE clause, and explicitly not a larger LIMIT.An absent reason falls back to stating the row count and claiming nothing about why. A result from a backend predating the field shouldn't be guessed at.
Derivation is now
truncation_for, which prefers memory when both apply. In the streaming path the guard cannot in fact be the answer — tripping it breaks out of the fetch loop, so the statement-complete marker never arrives and that case is handled after the loop. The branch is kept anyway so both sites derive the reason identically, and a change to the control flow cannot quietly restore the wrong advice.Verified
truncation_for, including memory winning over a simultaneously-reached row limitRowLimitwhen the limit is hit,Nonewhen it is nottruncationMessageFull local run: 1697 unit, 297 browser, 58 Rust lib, clippy/tsc/dprint/eslint clean.
Not verified
The post-loop
MemoryGuardblock firing under real memory pressure. The guard's 512 MB floor is hardcoded andexecuteconstructs the guard itself, so there is no way to provoke it without starving the machine. Every piece it depends on is covered; the block that joins them up is not.Filed as #540, which proposes an injectable floor. That issue also carries a related question I could not answer for the same reason: the timeout path deliberately kills the server-side statement before returning, and the memory path just stops reading — flagged as a question, not asserted as a bug.
🤖 Generated with Claude Code