lhotari commented on a change in pull request #10755:
URL: https://github.com/apache/pulsar/pull/10755#discussion_r642782389
##########
File path:
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java
##########
@@ -178,8 +178,21 @@ public void addComplete(int rc, final LedgerHandle lh,
long entryId, Object ctx)
@Override
public void safeRun() {
// Remove this entry from the head of the pending queue
- OpAddEntry firstInQueue = ml.pendingAddEntries.poll();
- checkArgument(this == firstInQueue);
+ OpAddEntry firstInQueue = ml.pollPendingAddEntry();
+ if (this != firstInQueue) {
+ log.warn("Expected OpAddEntry wasn't first in queue. expected={}
actual={}", this, firstInQueue);
+ ManagedLedgerException managedLedgerException =
+ new ManagedLedgerException("Expected OpAddEntry wasn't
first in queue.");
+ // fail both entries
+ try {
+ if (firstInQueue != null) {
+ firstInQueue.failed(managedLedgerException);
+ }
+ } finally {
+ failed(managedLedgerException);
Review comment:
that's true, but I guess that this PR is doing the right thing by
calling `.failed` on the entries to discard them if the execution gets to this
point? The previous behavior of using `checkArgument(this == firstInQueue)`
would throw an `IllegalArgumentException` and leak ByteBufs on the discarded
OpAddEntrys. Isn't this PR an improvement to that since it blocks the memory
leak?
The repro case in #10738 was able to reproduce these errors in the original
code amoung others.
@codelipenghui do you expect that some changes would be made to this PR?
--
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]