You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by lh...@apache.org on 2021/06/02 10:50:06 UTC
[pulsar] 01/01: Release OpAddEntry.data when entry is copied and
discarded (#10773)
This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 121305f39d8efd28701e7cf14957d4526c35df47
Author: Lari Hotari <lh...@apache.org>
AuthorDate: Wed Jun 2 13:48:45 2021 +0300
Release OpAddEntry.data when entry is copied and discarded (#10773)
Fixes #10738
There's a ByteBuf leak that happens in ledger rollover. The repro case in #10738 reproduces some Netty ByteBuf leaks that are detected by the Netty Leak detector.
Release `OpAddEntry.data` when the original entry is copied and discarded
This PR was split out of PR #10755 which was closed without merging.
---
.../java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
index 7b0ae90..b0ed298 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
@@ -36,6 +36,7 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.util.Recycler;
import io.netty.util.Recycler.Handle;
+import io.netty.util.ReferenceCountUtil;
import java.time.Clock;
import java.util.Collections;
import java.util.HashMap;
@@ -1399,6 +1400,8 @@ public class ManagedLedgerImpl implements ManagedLedger, CreateCallback {
if (existsOp.ledger != null) {
existsOp.close();
existsOp = OpAddEntry.create(existsOp.ml, existsOp.data, existsOp.callback, existsOp.ctx);
+ // release the extra retain
+ ReferenceCountUtil.release(existsOp.data);
}
existsOp.setLedger(currentLedger);
pendingAddEntries.add(existsOp);