merlimat commented on a change in pull request #7319:
URL: https://github.com/apache/pulsar/pull/7319#discussion_r443136519
##########
File path:
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
##########
@@ -3177,8 +3177,7 @@ protected void asyncCreateLedger(BookKeeper bookKeeper,
ManagedLedgerConfig conf
digestType, config.getPassword(), cb, ledgerCreated,
finalMetadata);
scheduledExecutor.schedule(() -> {
if (!ledgerCreated.get()) {
- ledgerCreated.set(true);
- cb.createComplete(BKException.Code.TimeoutException, null,
null);
+ cb.createComplete(BKException.Code.TimeoutException, null,
ledgerCreated);
Review comment:
It's not always the case. eg: In `createNewMetadataLedger()` when we
create a new cursor ledger, we pass a lambda and there's no mutex. The logic in
`checkAndCompleteLedgerOpTask()` seems race prone.
I think we should probably use compareAndSet() to manipulate that
`ledgerCreated` flag, which also might be better represented by an enum with
multiple states.
Finally (and this is unrelated to the bug here), we should try to cancel the
timeout task, once the create operation succeeds or fails before it times out.
Otherwise we can get into a state with many timer tasks pending.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]