BewareMyPower commented on code in PR #23951:
URL: https://github.com/apache/pulsar/pull/23951#discussion_r1947839974
##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java:
##########
@@ -1144,16 +1144,14 @@ 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);
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;
Review Comment:
From the PR description, it seems that we should only synchronize the
`initializeCursorPosition` method with `internalTrimLedgers`, would it be
better to just minimum the synchronize block like:
```java
void initializeCursorPosition(Pair<Position, Long> lastPositionCounter) {
synchronized (ledger) {
/* ... */
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]