Skip to content

Commit 183b27d

Browse files
poorbarcodenikhil-ctds
authored andcommitted
[fix][broker] Skip to persist cursor info if it failed by cursor closed (apache#23615)
(cherry picked from commit 9850605) (cherry picked from commit 86eb2a8)
1 parent 1a80cdc commit 183b27d

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
@@ -3137,6 +3137,13 @@ void persistPositionToLedger(final LedgerHandle lh, MarkDeleteEntry mdEntry, fin
31373137
mbean.addWriteCursorLedgerSize(data.length);
31383138
callback.operationComplete();
31393139
} else {
3140+
if (state == State.Closed) {
3141+
// After closed the cursor, the in-progress persistence task will get a
3142+
// BKException.Code.LedgerClosedException.
3143+
callback.operationFailed(new CursorAlreadyClosedException(String.format("%s %s skipped this"
3144+
+ " persistence, because the cursor already closed", ledger.getName(), name)));
3145+
return;
3146+
}
31403147
log.warn("[{}] Error updating cursor {} position {} in meta-ledger {}: {}", ledger.getName(), name,
31413148
position, lh1.getId(), BKException.getMessage(rc));
31423149
// 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)