Skip to content

Commit

Permalink
fix: register metrics after starting the wal
Browse files Browse the repository at this point in the history
Signed-off-by: Ning Yu <[email protected]>
  • Loading branch information
Chillax-0v0 committed Feb 5, 2024
1 parent b656c0e commit 706e4dd
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,11 @@ public WriteAheadLog start() throws IOException {
walHeaderReady(header);

started.set(true);
LOGGER.info("block WAL service started, cost: {} ms", stopWatch.getTime(TimeUnit.MILLISECONDS));
return this;
}

private void registerMetrics() {
S3StreamMetricsManager.registerDeltaWalOffsetSupplier(() -> {
try {
return this.getCurrentStartOffset();
Expand All @@ -299,9 +303,6 @@ public WriteAheadLog start() throws IOException {
return 0L;
}
}, () -> walHeader.getFlushedTrimOffset());

LOGGER.info("block WAL service started, cost: {} ms", stopWatch.getTime(TimeUnit.MILLISECONDS));
return this;
}

private long getCurrentStartOffset() {
Expand Down Expand Up @@ -480,7 +481,14 @@ public CompletableFuture<Void> reset() {
slidingWindowService.start(walHeader.getAtomicSlidingWindowMaxLength(), recoveryCompleteOffset);
}
LOGGER.info("reset sliding window to offset: {}", recoveryCompleteOffset);
return trim(recoveryCompleteOffset - 1, true).thenRun(() -> resetFinished.set(true));
CompletableFuture<Void> cf = trim(recoveryCompleteOffset - 1, true)
.thenRun(() -> resetFinished.set(true));

if (!recoveryMode) {
// Only register metrics when not in recovery mode
return cf.thenRun(this::registerMetrics);
}
return cf;
}

@Override
Expand Down

0 comments on commit 706e4dd

Please sign in to comment.