sijie commented on a change in pull request #5942: Avoid using same OpAddEntry 
between different ledger handles
URL: https://github.com/apache/pulsar/pull/5942#discussion_r363148792
 
 

 ##########
 File path: 
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
 ##########
 @@ -1294,9 +1293,24 @@ public synchronized void updateLedgersIdsComplete(Stat 
stat) {
             log.debug("[{}] Resending {} pending messages", name, 
pendingAddEntries.size());
         }
 
+        // Avoid use same OpAddEntry between different ledger handle
+        int pendingSize = pendingAddEntries.size();
+        OpAddEntry existsOp;
+        do {
+            existsOp = pendingAddEntries.poll();
+            if (existsOp != null) {
+                // If op is used by another ledger handle, we need to close it 
and create a new one
+                if (existsOp.ledger != null) {
+                    existsOp.close();
 
 Review comment:
   not sure we need to close here. I think once we duplicate the operation, we 
can just let the original callback close the old op. so it seems to me that we 
don't need introducing another `state` field here.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to