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 Jun 19, 2023
1 parent e03949a commit e442642
Showing 1 changed file with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -824,21 +824,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 @@ -858,6 +843,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 e442642

Please sign in to comment.