Arrow: Fix direct memory leak in row lineage vectorized readers#17296
Open
Neuw84 wants to merge 1 commit into
Open
Arrow: Fix direct memory leak in row lineage vectorized readers#17296Neuw84 wants to merge 1 commit into
Neuw84 wants to merge 1 commit into
Conversation
RowIdVectorReader and LastUpdatedSeqVectorReader allocated a fresh BigIntVector from the root allocator on every batch, ignored the reuse parameter, kept no reference to the returned vector and had no-op close() methods. Nothing downstream closes the holders' vectors either, so every batch of a vectorized read that projects _row_id or _last_updated_sequence_number leaked one direct-memory vector. On long-running Spark row-level operations against format-version 3 tables this grows without bound until the executor is killed (the identical workload against a v2 table runs flat, as the lineage readers are never instantiated). The readers now own their result vector like the base reader owns vec: they allocate it lazily, reuse it across batches while its capacity suffices and release it in close(), which also closes the delegate readers. New tests assert the root allocator returns to its baseline after close and fail against the previous implementation.
3 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.
RowIdVectorReader and LastUpdatedSeqVectorReader allocated a fresh BigIntVector from the root allocator on every batch, ignored the reuse parameter, kept no reference to the returned vector and had no-op close() methods. Nothing downstream closes the holders' vectors either, so every batch of a vectorized read that projects _row_id or _last_updated_sequence_number leaked one direct-memory vector.
On long-running Spark row-level operations against format-version 3 tables this grows without bound until the executor is killed (the identical workload against a v2 table runs flat, as the lineage readers are never instantiated).
The readers now own their result vector like the base reader owns vec: they allocate it lazily, reuse it across batches while its capacity suffices and release it in close(), which also closes the delegate readers. New tests assert the root allocator returns to its baseline after close and fail against the previous implementation.
AI Disclosure
Model: Claude Fable
Platform/Tool: Kiro
Human Oversight: reviewed
Relates to #17241