You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/06/02 00:34:34 UTC

[GitHub] [pulsar] codelipenghui commented on a change in pull request #10773: [ML] Release OpAddEntry.data when entry is copied and discarded

codelipenghui commented on a change in pull request #10773:
URL: https://github.com/apache/pulsar/pull/10773#discussion_r643571943



##########
File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
##########
@@ -1504,6 +1504,8 @@ public synchronized void updateLedgersIdsComplete(Stat stat) {
                 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);

Review comment:
       LGTM, just add more context here. We can safe to release the buffer here because we closed the old OpAddEntry, if the OpAddEntry in the closed state, even if the `addComplete` been called, will not use the buffer again.
   
   ```
           if (!STATE_UPDATER.compareAndSet(OpAddEntry.this, State.INITIATED, State.COMPLETED)) {
               log.warn("[{}] The add op is terminal legacy callback for entry {}-{} adding.", ml.getName(), lh.getId(), entryId);
               OpAddEntry.this.recycle();
               return;
           }
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org