Skip to content

Conversation

@TakaHiR07
Copy link
Contributor

@TakaHiR07 TakaHiR07 commented May 30, 2025

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.maxCapacityPerThread config. 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.

import org.apache.bookkeeper.net.BookieId;
import org.slf4j.MDC;

class AddCompletion extends CompletionValue implements BookkeeperInternalCallbacks.WriteCallback {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactoring by pulling the classes out masks the actual fix here. Can you, for this fix, leave the refactoring aside?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

import org.apache.bookkeeper.net.BookieId;
import org.slf4j.MDC;

class AddCompletion extends CompletionValue implements BookkeeperInternalCallbacks.WriteCallback {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 merlimat merged commit 87ca7f3 into apache:master Jun 2, 2025
23 checks passed
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>
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants