merlimat closed pull request #1544: Fix for 
cursorPersistenceAsyncMarkDeleteSameThread
URL: https://github.com/apache/incubator-pulsar/pull/1544
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
 
b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
index 277309095e..34efb5c0b8 100644
--- 
a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
+++ 
b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
@@ -81,7 +81,9 @@
 import org.apache.bookkeeper.mledger.proto.MLDataFormats.ManagedCursorInfo;
 import org.apache.bookkeeper.mledger.proto.MLDataFormats.PositionInfo;
 import org.apache.commons.lang3.tuple.Pair;
+import org.jctools.queues.MessagePassingQueue;
 import org.jctools.queues.MpmcArrayQueue;
+import org.jctools.queues.MpscLinkedQueue;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -149,7 +151,7 @@ public MarkDeleteEntry(PositionImpl newPosition, 
Map<String, Long> properties,
         }
     }
 
-    private final MpmcArrayQueue<MarkDeleteEntry> pendingMarkDeleteOps = new 
MpmcArrayQueue<>(16);
+    private final MessagePassingQueue<MarkDeleteEntry> pendingMarkDeleteOps = 
MpscLinkedQueue.newMpscLinkedQueue();
 
     private static final AtomicIntegerFieldUpdater<ManagedCursorImpl> 
PENDING_MARK_DELETED_SUBMITTED_COUNT_UPDATER =
         AtomicIntegerFieldUpdater.newUpdater(ManagedCursorImpl.class, 
"pendingMarkDeletedSubmittedCount");
@@ -1358,7 +1360,10 @@ protected void internalAsyncMarkDelete(final 
PositionImpl newPosition, Map<Strin
             startCreatingNewMetadataLedger();
             // fall through
         case SwitchingLedger:
-            pendingMarkDeleteOps.add(mdEntry);
+            if (!pendingMarkDeleteOps.offer(mdEntry)) {
+                callback.markDeleteFailed(new ManagedLedgerException("Cursor 
queue of mark-delete operations full"), ctx);
+                return;
+            }
             if (state != State.SwitchingLedger) {
                 // If state changed since we checked. Trigger a flush since we 
could have missed the current entry
                 flushPendingMarkDeletes();


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to