You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/03/14 01:17:16 UTC

[GitHub] [pulsar] codelipenghui commented on a change in pull request #14664: Fix lost message issue due to ledger rollover.

codelipenghui commented on a change in pull request #14664:
URL: https://github.com/apache/pulsar/pull/14664#discussion_r825535957



##########
File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
##########
@@ -1670,8 +1670,8 @@ boolean isNeededCreateNewLedgerAfterCloseLedger() {
     @Override
     public void rollCurrentLedgerIfFull() {
         log.info("[{}] Start checking if current ledger is full", name);
-        if (currentLedgerEntries > 0 && currentLedgerIsFull()) {
-            STATE_UPDATER.set(this, State.ClosingLedger);
+        if (currentLedgerEntries > 0 && currentLedgerIsFull()
+                && STATE_UPDATER.compareAndSet(this, State.LedgerOpened, State.ClosingLedger)) {

Review comment:
       For other states, we don't need to roll over the ledger. For example, if the state == `State.ClosingLedger`, means others already started the ledger rollover, we can skip the ledger full check at this time.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org