branch-4.1: [fix](arrow-flight-sql) Close temporary VectorSchemaRoot in createPreparedStatement to fix FE direct memory leak #65311#65751
Open
github-actions[bot] wants to merge 1 commit into
Conversation
…paredStatement to fix FE direct memory leak (#65311) ``` ### What problem does this PR solve? Issue Number: close #65305 Problem Summary: `DorisFlightSqlProducer#createPreparedStatement` creates two `VectorSchemaRoot` instances (an empty one for the parameter schema, and one from `FlightSqlChannel#createOneOneSchemaRoot(...)` for the result metadata), extracts only their `Schema`, and never closes them. `createOneOneSchemaRoot` allocates a `VarCharVector` from the channel `RootAllocator` (off-heap, Netty pooled direct buffer). Since the returned `VectorSchemaRoot` is never closed, its off-heap buffer is leaked on every prepare call (effectively every Arrow Flight query, because ADBC prepares each statement). The buffer cannot be reclaimed by GC (strongly referenced by the allocator) nor by closing the client session (`FlightSqlChannel#close()` only invalidates the result cache and does not close the allocator; the leaked root is never stored in any session map). Under continuous Arrow Flight query load this makes FE direct memory grow monotonically until: `java.lang.OutOfMemoryError: Cannot reserve ... bytes of direct buffer memory (Internal; Prepare)` This PR wraps both temporary roots in try-with-resources so their off-heap buffers are released after the `Schema` is extracted. `Schema` is an immutable POJO and remains valid after the root is closed. Compare with `getCatalogs`/`getSchemas`/`getTables` in the same producer, which already use try-with-resources. --------- Signed-off-by: 柳吟风 <523684989@qq.com> Signed-off-by: morningman <yunyou@selectdb.com> Co-authored-by: 柳吟风 <523684989@qq.com> Co-authored-by: morningman <yunyou@selectdb.com>
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
|
run buildall |
Contributor
FE Regression Coverage ReportIncrement line coverage |
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.
Cherry-picked from #65311