You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by pe...@apache.org on 2021/06/02 02:39:12 UTC

[pulsar] branch master updated: Release OpAddEntry.data when entry is copied and discarded (#10773)

This is an automated email from the ASF dual-hosted git repository.

penghui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 80e3034  Release OpAddEntry.data when entry is copied and discarded (#10773)
80e3034 is described below

commit 80e303438ccb9bd61bfd4f85d735474c823543f4
Author: Lari Hotari <lh...@users.noreply.github.com>
AuthorDate: Wed Jun 2 05:38:22 2021 +0300

    Release OpAddEntry.data when entry is copied and discarded (#10773)
    
    Fixes #10738
    
    ### Motivation
    
    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.
    
    ### Modifications
    
    Release `OpAddEntry.data` when the original entry is copied and discarded
    
    ### Additional Context
    
    This PR was split out of PR #10755 which was closed without merging.
---
 .../main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java | 2 ++
 1 file changed, 2 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 a338c30..9c6c21f 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
@@ -1504,6 +1504,8 @@ public class ManagedLedgerImpl implements ManagedLedger, CreateCallback {
                 if (existsOp.ledger != null) {
                     existsOp.close();
                     existsOp = OpAddEntry.create(existsOp.ml, existsOp.data, existsOp.getNumberOfMessages(), existsOp.callback, existsOp.ctx);
+                    // release the extra retain
+                    ReferenceCountUtil.release(existsOp.data);
                 }
                 existsOp.setLedger(currentLedger);
                 if (beforeAddEntry(existsOp)) {