Skip to content

Commit 4a3090d

Browse files
poorbarcodehanmz
authored andcommitted
[fix][broker] Skip to persist cursor info if it failed by cursor closed (apache#23615)
1 parent f8ac1cf commit 4a3090d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3254,6 +3254,13 @@ void persistPositionToLedger(final LedgerHandle lh, MarkDeleteEntry mdEntry, fin
32543254
mbean.addWriteCursorLedgerSize(data.length);
32553255
callback.operationComplete();
32563256
} else {
3257+
if (state == State.Closed) {
3258+
// After closed the cursor, the in-progress persistence task will get a
3259+
// BKException.Code.LedgerClosedException.
3260+
callback.operationFailed(new CursorAlreadyClosedException(String.format("%s %s skipped this"
3261+
+ " persistence, because the cursor already closed", ledger.getName(), name)));
3262+
return;
3263+
}
32573264
log.warn("[{}] Error updating cursor {} position {} in meta-ledger {}: {}", ledger.getName(), name,
32583265
position, lh1.getId(), BKException.getMessage(rc));
32593266
// If we've had a write error, the ledger will be automatically closed, we need to create a new one,

0 commit comments

Comments
 (0)