lordcheng10 commented on code in PR #18042:
URL: https://github.com/apache/pulsar/pull/18042#discussion_r997777250


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java:
##########
@@ -1868,7 +1868,15 @@ public void asyncMarkDelete(final Position position, 
Map<String, Long> propertie
 
         if (config.isDeletionAtBatchIndexLevelEnabled() && batchDeletedIndexes 
!= null) {
             if (newPosition.ackSet != null) {
-                batchDeletedIndexes.put(newPosition, 
BitSetRecyclable.create().resetWords(newPosition.ackSet));
+                lock.writeLock().lock();
+                try {
+                    BitSetRecyclable givenBitSet = 
BitSetRecyclable.create().resetWords(newPosition.ackSet);
+                    batchDeletedIndexes.compute(newPosition,
+                            (k, v) -> v == null || givenBitSet.nextSetBit(0) > 
v.nextSetBit(0)
+                                    ? givenBitSet : v);

Review Comment:
   For mark delete, if the batch index to be confirmed is 3, then the binary 
for mark delete should be: 11000, not 11011. 0 means acked.
   For example, the received batch index binary digits are 111000, 11000, and 
101000 and 100001 cannot appear:
   <img width="1481" alt="image" 
src="https://user-images.githubusercontent.com/19296967/196354078-c6727497-0e88-4f13-8370-f5d1c9b33186.png";>



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