[lake/tiering] Fix lake writer resource leak in TieringSplitReader close chain#3720
Open
beryllw wants to merge 2 commits into
Open
[lake/tiering] Fix lake writer resource leak in TieringSplitReader close chain#3720beryllw wants to merge 2 commits into
beryllw wants to merge 2 commits into
Conversation
Contributor
Author
|
@luoyuxia cc |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a resource-leak/masked-exception issue in Fluss’ Flink tiering source by ensuring in-flight lake writers are reliably closed (including on failure paths) before closing the log scanner/allocator chain, and by adding a shared utility to close multiple resources while preserving the first failure and suppressing the rest.
Changes:
- Make
TieringSplitReaderalways close lake writers whencomplete()fails, when closing the reader, and defensively when switching/finishing tables. - Introduce
IOUtils.closeAll()to close a collection ofAutoCloseables while throwing the first exception and suppressing subsequent ones. - Add/extend unit tests to validate lake writers are closed on normal completion, on
complete()failure, and on split-reader close with writers still in-flight.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/tiering/source/TieringSplitReader.java | Ensures lake writers are closed on failure and in close/finish paths; closes writers before log scanner to avoid Arrow allocator leak errors masking root causes. |
| fluss-common/src/main/java/org/apache/fluss/utils/IOUtils.java | Adds closeAll() helper to close groups of resources and propagate the first close failure with others suppressed. |
| fluss-common/src/test/java/org/apache/fluss/utils/IOUtilsTest.java | Adds coverage for IOUtils.closeAll() behavior (null tolerance, suppression semantics, and closing all elements). |
| fluss-flink/fluss-flink-common/src/test/java/org/apache/fluss/flink/tiering/TestingLakeTieringFactory.java | Enhances the testing factory to track created writers, inject complete() failures, and expose closed state for assertions. |
| fluss-flink/fluss-flink-common/src/test/java/org/apache/fluss/flink/tiering/source/TieringSplitReaderTest.java | Adds assertions/tests verifying writers are closed on normal completion, on complete() failure, and during reader close while writers are still in-flight. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
beryllw
force-pushed
the
fix-tiering-split-reader-close-leak
branch
from
July 22, 2026 03:11
1fe0f78 to
ad1d020
Compare
luoyuxia
approved these changes
Jul 22, 2026
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.
Purpose
Linked issue: close #3719
TieringSplitReadernever closes in-flight lake writers on failure. The leaked Arrow buffers make the log scanner close fail with "Memory was leaked by query", masking the real exception during failover.Brief change log
completeLakeWriter(): always close the writer even whencomplete()throws.close(): close all in-flight lake writers (before the log scanner, since their Arrow buffers are allocated from it) and the snapshot split reader.finishCurrentTable(): close residual writers before switching tables.IOUtils.closeAll()(aligned with Flink) to close a group of resources and throw the first failure with the rest suppressed.https://github.com/apache/flink/blob/c643a2953ba44b3b316ba52983932329dc0162e4/flink-core/src/main/java/org/apache/flink/util/IOUtils.java#L245-L271
Tests
API and Format
Documentation