mattisonchao commented on PR #22034:
URL: https://github.com/apache/pulsar/pull/22034#issuecomment-1952382371
Hi, guys.
I can't say the new method has problems so far. I just worry that we have
broken the lazy ledger creation logic.
How about changing the `rollCurrentLedgerIfFull` method to be as follows?
The schedule rollover checker will roll the current closed ledger after
`maximumRolloverTimeMs`
```java
public void rollCurrentLedgerIfFull() {
log.info("[{}] Start checking if current ledger is full", name);
if (currentLedgerEntries <= 0 || !currentLedgerIsFull()) {
return;
}
if(STATE_UPDATER.compareAndSet(this, State.LedgerOpened,
State.ClosingLedger)) {
currentLedger.asyncClose(new AsyncCallback.CloseCallback() {
@Override
public void closeComplete(int rc, LedgerHandle lh, Object o)
{
checkArgument(currentLedger.getId() == lh.getId(),
"ledgerId %s doesn't match with "
+
"acked ledgerId %s", currentLedger.getId(), lh.getId());
if (rc == BKException.Code.OK) {
if (log.isDebugEnabled()) {
log.debug("[{}] Successfully closed ledger {},
trigger by rollover full ledger",
name, lh.getId());
}
} else {
log.warn("[{}] Error when closing ledger {}, trigger
by rollover full ledger, Status={}",
name, lh.getId(),
BKException.getMessage(rc));
}
ledgerClosed(lh);
createLedgerAfterClosed();
}
}, null);
} else if (STATE_UPDATER.get(this) == State.ClosedLedger) {
createLedgerAfterClosed();
}
}
```
--
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]