Skip to content

Commit

Permalink
Fix memory leak when the Bookie is in read-only mode. (#3746)
Browse files Browse the repository at this point in the history
Descriptions of the changes in this PR:
Fixes #3745
  • Loading branch information
horizonzy committed Feb 8, 2023
1 parent 02e64a4 commit af82d14
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public Object decode(ByteBuf packet)
packet.markReaderIndex();
return BookieProtocol.ParsedAddRequest.create(
version, ledgerId, entryId, flags,
masterKey, packet.retain());
masterKey, packet);
}

case BookieProtocol.READENTRY:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ public void run() {
if (request instanceof BookieProtocol.ReadRequest) {
requestProcessor.onReadRequestFinish();
}
if (request instanceof BookieProtocol.AddRequest) {
if (request instanceof BookieProtocol.ParsedAddRequest) {
((BookieProtocol.ParsedAddRequest) request).release();
request.recycle();
requestProcessor.onAddRequestFinish();
}
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.util.Recycler;
import io.netty.util.ReferenceCountUtil;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.apache.bookkeeper.bookie.BookieException;
Expand Down Expand Up @@ -101,8 +100,6 @@ protected void processPacket() {
request.ledgerId, request.entryId, t.getMessage(), t);
// some bad request which cause unexpected exception
rc = BookieProtocol.EBADREQ;
} finally {
ReferenceCountUtil.safeRelease(addData);
}

if (rc != BookieProtocol.EOK) {
Expand Down

0 comments on commit af82d14

Please sign in to comment.