Skip to content

Commit 35c4c77

Browse files
committed
[fix][broker] Optimize logic
1 parent 7a03c7b commit 35c4c77

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,12 +2184,11 @@ public void asyncMarkDelete(final Position position, Map<String, Long> propertie
21842184
// Snapshot all positions into local variables to avoid race condition.
21852185
Position newPosition = ackBatchPosition(position);
21862186
Position moveForwardPosition = newPosition;
2187-
Position lastConfirmedEntry = ledger.getLastConfirmedEntry();
21882187
Position markDeletePos = markDeletePosition;
2188+
Position lastConfirmedEntry = ledger.getLastConfirmedEntry();
21892189
boolean shouldCursorMoveForward = false;
21902190
try {
2191-
// Keep all comparison cases here for future modification.
2192-
if (lastConfirmedEntry.getLedgerId() > newPosition.getLedgerId()) {
2191+
if (lastConfirmedEntry.getLedgerId() >= newPosition.getLedgerId()) {
21932192
LedgerInfo curMarkDeleteledgerInfo = ledger.getLedgerInfo(newPosition.getLedgerId()).get();
21942193
Long nextValidLedger = ledger.getNextValidLedger(newPosition.getLedgerId());
21952194
shouldCursorMoveForward = (nextValidLedger != null)
@@ -2198,15 +2197,6 @@ public void asyncMarkDelete(final Position position, Map<String, Long> propertie
21982197
if (shouldCursorMoveForward) {
21992198
moveForwardPosition = PositionFactory.create(nextValidLedger, -1);
22002199
}
2201-
} else if (lastConfirmedEntry.getLedgerId() == newPosition.getLedgerId()) {
2202-
LedgerInfo curMarkDeleteledgerInfo = ledger.getLedgerInfo(newPosition.getLedgerId()).get();
2203-
Long nextValidLedger = ledger.getNextValidLedger(lastConfirmedEntry.getLedgerId());
2204-
shouldCursorMoveForward = (nextValidLedger != null)
2205-
&& (curMarkDeleteledgerInfo != null
2206-
&& newPosition.getEntryId() + 1 >= curMarkDeleteledgerInfo.getEntries());
2207-
if (shouldCursorMoveForward) {
2208-
moveForwardPosition = PositionFactory.create(nextValidLedger, -1);
2209-
}
22102200
} else {
22112201
Long nextValidLedger = ledger.getNextValidLedger(lastConfirmedEntry.getLedgerId());
22122202
shouldCursorMoveForward = (nextValidLedger != null)

0 commit comments

Comments
 (0)