[lake/iceberg] Fix listener leak in IcebergLakeCommitter#3542
Merged
luoyuxia merged 2 commits intoJun 30, 2026
Conversation
…ng snapshot listener only once
luoyuxia
reviewed
Jun 30, 2026
luoyuxia
left a comment
Contributor
There was a problem hiding this comment.
@Guosmilesmile Thanks for the pr. lgtm overall. I only left one comment
| import static org.apache.fluss.lake.iceberg.utils.IcebergConversions.toIceberg; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class IcebergLakeCommitterListenerLeakTest { |
Contributor
There was a problem hiding this comment.
Can we just remove this test since it's a trival change and the behavior is already coverd by existing test
Contributor
Author
There was a problem hiding this comment.
Sure, remove IcebergLakeCommitterListenerLeakTest.
Contributor
Author
|
Thanks @luoyuxia for reviewing ! |
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
Because Iceberg's
Listenersregistry is:staticMap<Class, Queue<Listener>>),deregister/unregisterAPI),every newly created
IcebergLakeCommitterpermanently appended one morelistener to the global queue. In a long-running tiering job, the queue keeps
growing and every
CreateSnapshotEventis dispatched to all of them,causing:
as the
Listenersclass is loaded.where N grows over time.
IcebergLakeCommitterinstances live in the same JVM (e.g. multiple tiering tasks), all of their listeners write to the sameThreadLocal<Long> currentCommitSnapshotId. The last writer wins, but the duplicated work is still wasted.Brief change log
static {}block inIcebergLakeCommitter, so the listener is registered exactly once perClassLoader (effectively once per JVM).
ThreadLocal#remove()call after each commit so no thread-localentry is leaked across commits.
IcebergLakeCommitterListenerLeakTestwhich:Listeners.LISTENERSregistry.IcebergLakeCommitterinstances.IcebergSnapshotCreateListenerinstances in the registry stays at exactly 1, regardless of how many committers are constructed.Tests
The behavior is already coverd by existing test.
API and Format
No public API or storage format change.
Documentation
No documentation change; behavior-only fix.