Skip to content

Commit

Permalink
fix wrong update checkAllLedgersTime when ledgerReplication disabled (#…
Browse files Browse the repository at this point in the history
…3939)

### Motivation

When ledgerReplication disabled, we don't need to register `checkAllLedgersTime` failedEvent because we already skipped the check and didn't encounter any exception.

```java
        Stopwatch stopwatch = Stopwatch.createStarted();
        boolean checkSuccess = false;
        try {
            if (!isLedgerReplicationEnabled()) {
                LOG.info("Ledger replication disabled, skipping checkAllLedgers");
                checkSuccess = true;    <= here
                return;
            }

            LOG.info("Starting checkAllLedgers");
            checkAllLedgers();
            ......
            checkSuccess = true;
        } catch (InterruptedException ie) {
           ......
        } finally {
            if (!checkSuccess) {
                long checkAllLedgersDuration = stopwatch.stop().elapsed(TimeUnit.MILLISECONDS);
                auditorStats.getCheckAllLedgersTime()
                        .registerFailedEvent(checkAllLedgersDuration, TimeUnit.MILLISECONDS);
            }
        }
```
  • Loading branch information
wenbingshen committed Apr 27, 2023
1 parent 3a9fe1b commit c765aea
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ protected void runTask() {
try {
if (!isLedgerReplicationEnabled()) {
LOG.info("Ledger replication disabled, skipping checkAllLedgers");
checkSuccess = true;
return;
}

Expand Down

0 comments on commit c765aea

Please sign in to comment.