Skip to content

Commit d8c1f1a

Browse files
author
graysonzeng
committed
[fix] make sure the pendingAddOps.remove() and pendingAddOps.peek() process the same element
1 parent 4a4d1b2 commit d8c1f1a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,11 @@ void sendAddSuccessCallbacks() {
18361836
return;
18371837
}
18381838

1839-
pendingAddOps.remove();
1839+
if (!pendingAddOps.remove(pendingAddOp)) {
1840+
// If the remove operation fails, it means the element has already been removed by another thread.
1841+
// We should continue to the next iteration to process the next element.
1842+
continue;
1843+
}
18401844
explicitLacFlushPolicy.updatePiggyBackedLac(lastAddConfirmed);
18411845
pendingAddsSequenceHead = pendingAddOp.entryId;
18421846
if (!writeFlags.contains(WriteFlag.DEFERRED_SYNC)) {

0 commit comments

Comments
 (0)