congbobo184 commented on code in PR #15067:
URL: https://github.com/apache/pulsar/pull/15067#discussion_r845812947


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java:
##########
@@ -1814,6 +1876,9 @@ public void operationComplete() {
                             mdEntry.newPosition);
                 }
 
+                
INPROGRESS_MARKDELETE_PERSIST_POSITION_UPDATER.compareAndSet(ManagedCursorImpl.this,
+                        mdEntry.newPosition, null);
+

Review Comment:
   we should make sure only one `persistPositionToLedger ` op in the same time. 
we should lock update persistentMarkDeletePosition and update 
INPROGRESS_MARKDELETE_PERSIST_POSITION_UPDATER like : 
   ```
           try {
               lock.writeLock().lock();
               if((persistentMarkDeletePosition == null ||
                       
mdEntry.newPosition.compareTo(persistentMarkDeletePosition) > 0) && 
PENDING_MARK_DELETED_SUBMITTED_COUNT_UPDATER.compareAndSet(this, null, 
mdEntry.newPosition)) {
                   persistPositionToLedger(cursorLedger, mdEntry, new 
VoidCallback() {
                       public void operationComplete() {
                           try {
                               lock.writeLock().lock();
                               
INPROGRESS_MARKDELETE_PERSIST_POSITION_UPDATER.compareAndSet(ManagedCursorImpl.this,
                                       mdEntry.newPosition, null);
                               persistentMarkDeletePosition = 
mdEntry.newPosition;
                           } finally {
                               lock.writeLock().unlock();
                           }
                       }
                   }
               }
           } finally {
               lock.writeLock().unlock();
           }
   ```
   of cause you only use a flag not use 
INPROGRESS_MARKDELETE_PERSIST_POSITION_UPDATER is also can implement



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to