fix: resource leak when JournalChannel is not fully initialized#4340
Merged
Conversation
hezhangjian
force-pushed
the
journal-channel-close
branch
from
May 5, 2024 09:59
b179ec0 to
1e0fe59
Compare
hezhangjian
requested review from
StevenLuMT,
dlg99,
eolivelli,
hangc0276,
nicoloboschi and
zymap
May 5, 2024 10:27
eolivelli
reviewed
May 6, 2024
eolivelli
requested changes
May 6, 2024
hezhangjian
force-pushed
the
journal-channel-close
branch
from
May 6, 2024 06:41
1e0fe59 to
9c9a669
Compare
Signed-off-by: ZhangJian He <shoothzj@gmail.com>
hezhangjian
force-pushed
the
journal-channel-close
branch
from
May 8, 2024 05:29
9c9a669 to
879e2c1
Compare
Member
Author
|
@dlg99 @eolivelli @hangc0276 @merlimat @nicoloboschi @StevenLuMT @wenbingshen @zhaijack PTAL |
hezhangjian
pushed a commit
that referenced
this pull request
May 25, 2024
(cherry picked from commit 82a7dd3)
hezhangjian
pushed a commit
that referenced
this pull request
May 25, 2024
(cherry picked from commit 82a7dd3)
Ghatage
pushed a commit
to sijie/bookkeeper
that referenced
this pull request
Jul 12, 2024
lhotari
pushed a commit
that referenced
this pull request
Apr 17, 2025
(cherry picked from commit 82a7dd3)
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.
Motivation
There is a resource leak in the
JournalChannelimplementation of Apache Bookkeeper when the channel is closed before it is fully initialized (specifically, before the writing of headers begins). In such cases, the buffer channel (bc) is not yet instantiated, but the file channel (fc) might already be open.Changes
Updated the
close()method inJournalChannelto include a conditional check that closes the file channel (fc) if the buffer channel (bc) is null. This ensures that all resources are properly released, even if theJournalChannelis prematurely closed before full initialization.wrie header method
bookkeeper/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/JournalChannel.java
Lines 250 to 265 in ba7f988