devinbost commented on a change in pull request #10755:
URL: https://github.com/apache/pulsar/pull/10755#discussion_r643400402



##########
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:
       Looks like it's only removed according to the state, but if the sanity 
check fails, it's not handled right. 




-- 
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]


Reply via email to