Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bookie] Fix memory leak when the Bookie is in read only mode #3746

Merged
merged 1 commit into from
Feb 8, 2023

Conversation

horizonzy
Copy link
Member

Descriptions of the changes in this PR:
Fixes #3745

@horizonzy horizonzy force-pushed the fix-memory-leak-when-read-only branch from 3eb33bb to 4576422 Compare January 18, 2023 02:45
Copy link
Member

@wenbingshen wenbingshen left a comment

Choose a reason for hiding this comment

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

Good catch!
Very detailed investigation and explanation!

Comment on lines +178 to 181
if (request instanceof BookieProtocol.ParsedAddRequest) {
((BookieProtocol.ParsedAddRequest) request).release();
request.recycle();
requestProcessor.onAddRequestFinish();
Copy link
Member

Choose a reason for hiding this comment

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

Can the release of ParsedAddRequest be executed in the recycle method? It seems that these two methods are always used together, and there is a forced switch here, which seems a bit awkward.

You can look at org.apache.bookkeeper.proto.BookieProtocol.AddRequest#recycle method

        @Override
        public void recycle() {
            ledgerId = -1;
            entryId = -1;
            masterKey = null;
            ReferenceCountUtil.safeRelease(data);
            data = null;
            recyclerHandle.recycle(this);
        }

Copy link
Member Author

Choose a reason for hiding this comment

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

It can't, we shouldn't release the data in the recycle.
In the normal case, it will recycle the request, but the data is already free.

See:

Copy link
Member

Choose a reason for hiding this comment

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

I saw it, sorry I misread it earlier. Nice work. Thanks.

Copy link
Contributor

@hangc0276 hangc0276 left a comment

Choose a reason for hiding this comment

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

Great job!

Copy link
Contributor

@StevenLuMT StevenLuMT left a comment

Choose a reason for hiding this comment

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

LGTM

@hangc0276
Copy link
Contributor

@merlimat @eolivelli @dlg99 @zymap Please help take a look at this PR, thanks.

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

Great catch

@eolivelli eolivelli changed the title Fix memory leak when read only [bookie] Fix memory leak when the Bookie is in read only mode Feb 7, 2023
@hangc0276 hangc0276 merged commit af82d14 into apache:master Feb 8, 2023
hangc0276 pushed a commit that referenced this pull request Feb 8, 2023
Descriptions of the changes in this PR:
Fixes #3745

(cherry picked from commit af82d14)
zymap pushed a commit that referenced this pull request Feb 16, 2023
Descriptions of the changes in this PR:
Fixes #3745

(cherry picked from commit af82d14)
gaozhangmin pushed a commit to gaozhangmin/bookkeeper that referenced this pull request Feb 23, 2023
nicoloboschi pushed a commit to datastax/bookkeeper that referenced this pull request Mar 13, 2023
Descriptions of the changes in this PR:
Fixes apache#3745

(cherry picked from commit af82d14)
(cherry picked from commit 9e0e198)
nicoloboschi pushed a commit to datastax/bookkeeper that referenced this pull request Mar 13, 2023
Descriptions of the changes in this PR:
Fixes apache#3745

(cherry picked from commit af82d14)
(cherry picked from commit 9e0e198)
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.

Bookie server memory leak when read-olny open
7 participants