Fix Memory Leak In Netty Recycler of Bookie Client#4609
Merged
Conversation
merlimat
reviewed
May 30, 2025
| import org.apache.bookkeeper.net.BookieId; | ||
| import org.slf4j.MDC; | ||
|
|
||
| class AddCompletion extends CompletionValue implements BookkeeperInternalCallbacks.WriteCallback { |
Contributor
There was a problem hiding this comment.
Refactoring by pulling the classes out masks the actual fix here. Can you, for this fix, leave the refactoring aside?
Contributor
There was a problem hiding this comment.
Actually, after reviewing a bit, it kind of makes sense to split the classes in this PR, since it forces all classes to be static.
merlimat
reviewed
May 30, 2025
| import org.apache.bookkeeper.net.BookieId; | ||
| import org.slf4j.MDC; | ||
|
|
||
| class AddCompletion extends CompletionValue implements BookkeeperInternalCallbacks.WriteCallback { |
Contributor
There was a problem hiding this comment.
Actually, after reviewing a bit, it kind of makes sense to split the classes in this PR, since it forces all classes to be static.
merlimat
approved these changes
Jun 2, 2025
merlimat
added a commit
that referenced
this pull request
Jun 2, 2025
* make recycler static to avoid OOM problem * Fixed missing license headers * Fixed checkstyle * More checkstyle --------- Co-authored-by: fanjianye <fanjianye@bigo.sg> Co-authored-by: Matteo Merli <mmerli@apache.org>
3 tasks
priyanshu-ctds
pushed a commit
to datastax/bookkeeper
that referenced
this pull request
Jul 11, 2025
* make recycler static to avoid OOM problem * Fixed missing license headers * Fixed checkstyle * More checkstyle --------- Co-authored-by: fanjianye <fanjianye@bigo.sg> Co-authored-by: Matteo Merli <mmerli@apache.org> (cherry picked from commit 137cc94)
sandeep-ctds
pushed a commit
to datastax/bookkeeper
that referenced
this pull request
Jul 22, 2025
* make recycler static to avoid OOM problem * Fixed missing license headers * Fixed checkstyle * More checkstyle --------- Co-authored-by: fanjianye <fanjianye@bigo.sg> Co-authored-by: Matteo Merli <mmerli@apache.org> (cherry picked from commit 137cc94)
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.
Main Issue: apache/pulsar#24355
Motivation
There is a huge memory leak risk in netty recycler of bookie client . The issue and analysis is show here: apache/pulsar#24355
Changes
Currently, each perChannelBookieClient has its own recycler.
After modification, All the completionKey and completionValue is no longer the inner class of perChannelBookieClient, and each perChannelBookieClient would share the same recycler.
Notice: after the modification, it is more important to set a appropriate
io.netty.recycler.maxCapacityPerThreadconfig. Because I have tested that if we do not rely on cache object, the read and write performance would have a little decrease. Since all the channel in bkClient share the same recycler, we should make the config = add entry qps * add entry average latency.