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/08/23 17:22:19 UTC

[GitHub] [pulsar] michaeljmarshall commented on a change in pull request #11737: Fix the topic in fenced state and can not recover.

michaeljmarshall commented on a change in pull request #11737:
URL: https://github.com/apache/pulsar/pull/11737#discussion_r694141533



##########
File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java
##########
@@ -179,7 +179,18 @@ public void addComplete(int rc, final LedgerHandle lh, long entryId, Object ctx)
     public void safeRun() {
         // Remove this entry from the head of the pending queue
         OpAddEntry firstInQueue = ml.pendingAddEntries.poll();
-        checkArgument(this == firstInQueue);
+        if (firstInQueue == null) {
+            // The pending op might been polled by others such as cleanup pending op when create Ledger failed.
+            ReferenceCountUtil.release(data);
+            this.recycle();
+            return;
+        }
+        if (this != firstInQueue) {
+            firstInQueue.failed(new ManagedLedgerException("Unexpected add entry op when complete the add entry op."));
+            ReferenceCountUtil.release(data);
+            this.recycle();
+            return;
+        }

Review comment:
       +1. @codelipenghui, can you explain why we call `firstInQueue.failed` and then release `this.data` and call `this.recycle()` without also calling `this.failed`? Note that the `failed` method has concurrency controls built in by using the `callbackUpdater`. Wouldn't we want to use those concurrency controls here as well?
   
   ```java
       public void failed(ManagedLedgerException e) {
           AddEntryCallback cb = callbackUpdater.getAndSet(this, null);
           if (cb != null) {
               ReferenceCountUtil.release(data);
               cb.addFailed(e, ctx);
               ml.mbean.recordAddEntryError();
           }
       }
   ```




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

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

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