Skip to content

Commit

Permalink
[fix] [ml] incorrect non-durable cursor's backlog due to concurrently…
Browse files Browse the repository at this point in the history
… trimming ledger and non-durable cursor creation (#23951)

Co-authored-by: Yunze Xu <[email protected]>
  • Loading branch information
poorbarcode and BewareMyPower authored Feb 11, 2025
1 parent 20b3b22 commit cc7b381
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1152,16 +1152,17 @@ public ManagedCursor newNonDurableCursor(Position startCursorPosition, String cu
return cachedCursor;
}

NonDurableCursorImpl cursor = new NonDurableCursorImpl(bookKeeper, this, cursorName,
startCursorPosition, initialPosition, isReadCompacted);
cursor.setActive();

log.info("[{}] Opened new cursor: {}", name, cursor);
// The backlog of a non-durable cursor could be incorrect if the cursor is created before `internalTrimLedgers`
// and added to the managed ledger after `internalTrimLedgers`.
// For more details, see https://github.com/apache/pulsar/pull/23951.
synchronized (this) {
NonDurableCursorImpl cursor = new NonDurableCursorImpl(bookKeeper, this, cursorName,
startCursorPosition, initialPosition, isReadCompacted);
cursor.setActive();
log.info("[{}] Opened new cursor: {}", name, cursor);
addCursor(cursor);
return cursor;
}

return cursor;
}

@Override
Expand Down

0 comments on commit cc7b381

Please sign in to comment.