Ensure cached query results are discarded #11452
Merged
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.
Description
Fix.
Previous attempt was da2cd0a, but it doesn't work out in the following cases:
getNextResult
once, on the first calllastResult
is null, we will not have the next token to clear the cached resultThis PR improves the logic to check
resultRows
, aslastResult
will be set to aQueryResults
containingresultRows
at the end. If it's non-empty, then we need next token to clear the cached result. Note that thequeryInfo.getOutputStage().isPresent()
check is needed astrino/core/trino-main/src/main/java/io/trino/server/protocol/Query.java
Lines 510 to 515 in 736c160
Core engine.
This ensures cached query results are discarded upon completion, which improves memory usage of coordinator.
Related issues, pull requests, and links
Documentation
(x) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
(x) No release notes entries required.
( ) Release notes entries required with the following suggested text: