You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by yo...@apache.org on 2023/06/19 07:42:26 UTC
[bookkeeper] 02/31: Execute clean indexes in finally (#3772)
This is an automated email from the ASF dual-hosted git repository.
yong pushed a commit to branch branch-4.16
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
commit e44264270bdcbd09588a05910696c2f2554bd9a5
Author: Zhangao <ga...@qq.com>
AuthorDate: Fri Apr 7 15:08:42 2023 +0800
Execute clean indexes in finally (#3772)
Execute clean indexes in finally (#3772)
(cherry picked from commit 04e572b9bccd1502c0f2c4a87f23d760d4d0d9b5)
---
.../ldb/SingleDirectoryDbLedgerStorage.java | 29 +++++++++++-----------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java
index 635a2727f9..9f089d9864 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java
@@ -824,21 +824,6 @@ public class SingleDirectoryDbLedgerStorage implements CompactableLedgerStorage
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
@@ -858,6 +843,20 @@ public class SingleDirectoryDbLedgerStorage implements CompactableLedgerStorage
// 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 {