Skip to content

Commit

Permalink
Execute clean indexes in finally
Browse files Browse the repository at this point in the history
  • Loading branch information
gavingaozhangmin committed Feb 9, 2023
1 parent b85ac48 commit c65b06d
Showing 1 changed file with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -800,21 +800,6 @@ public void checkpoint(Checkpoint checkpoint) throws IOException {
ledgerIndex.flush();
recordSuccessfulEvent(dbLedgerStorageStats.getFlushLedgerIndexStats(), ledgerIndexStartTime);

cleanupExecutor.execute(() -> {
// There can only be one single cleanup task running because the cleanupExecutor
// is single-threaded
try {
if (log.isDebugEnabled()) {
log.debug("Removing deleted ledgers from db indexes");
}

entryLocationIndex.removeOffsetFromDeletedLedgers();
ledgerIndex.removeDeletedLedgers();
} catch (Throwable t) {
log.warn("Failed to cleanup db indexes", t);
}
});

lastCheckpoint = thisCheckpoint;

// Discard all the entry from the write cache, since they're now persisted
Expand All @@ -838,6 +823,20 @@ public void checkpoint(Checkpoint checkpoint) throws IOException {
// Wrap unchecked exceptions
throw new IOException(e);
} finally {
cleanupExecutor.execute(() -> {
// There can only be one single cleanup task running because the cleanupExecutor
// is single-threaded
try {
if (log.isDebugEnabled()) {
log.debug("Removing deleted ledgers from db indexes");
}

entryLocationIndex.removeOffsetFromDeletedLedgers();
ledgerIndex.removeDeletedLedgers();
} catch (Throwable t) {
log.warn("Failed to cleanup db indexes", t);
}
});
try {
isFlushOngoing.set(false);
} finally {
Expand Down

0 comments on commit c65b06d

Please sign in to comment.