Skip to content

Commit

Permalink
Fix memory leak when the Bookie is in read-only mode. (apache#3746)
Browse files Browse the repository at this point in the history
Descriptions of the changes in this PR:
Fixes apache#3745

(cherry picked from commit af82d14)
(cherry picked from commit 9e0e198)
  • Loading branch information
horizonzy authored and nicoloboschi committed Mar 13, 2023
1 parent 29e8438 commit b4ded3d
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 @@ -173,7 +173,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 @@ -176,7 +176,9 @@ public void safeRun() {
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 java.io.IOException;
import java.util.concurrent.TimeUnit;

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 {
addData.release();
}

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

0 comments on commit b4ded3d

Please sign in to comment.