codelipenghui 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_r363271357
##########
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:
We need to close the original op, otherwise when the old op callback, will
poll the first op in the pendingAddEntries
https://github.com/apache/pulsar/blob/ef23a4b0ef82db67cd6610d6fe82dc7aae1d3414/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java#L165
But, the first op is the new op we replaced.
----------------------------------------------------------------
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