Skip to content

Commit

Permalink
Execute clean indexes in finally (#3772)
Browse files Browse the repository at this point in the history
Execute clean indexes in finally (#3772)

(cherry picked from commit 04e572b)
  • Loading branch information
gaozhangmin authored and zymap committed Dec 6, 2023
1 parent 2eb1c36 commit 1ab2a41
Showing 1 changed file with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -754,21 +754,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 @@ -788,6 +773,20 @@ public void checkpoint(Checkpoint checkpoint) throws IOException {
// Leave IOExecption as it is
throw 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 1ab2a41

Please sign in to comment.