This is an automated email from the ASF dual-hosted git repository.

yong pushed a commit to branch branch-4.15
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git

commit 452f7a744a2d9336e567f34e9f73c56332a6f3b1
Author: zhaohaidao <[email protected]>
AuthorDate: Tue Oct 25 11:28:29 2022 +0800

    Flush time started moved to after lock (#3570)
    
    ### Motivation
    
    In BP-44(Ledger storage metrics enhancement), ledger flush start time is 
moved to after lock to avoid 200% time
      utilization calculations.
    However, 200% time utilization still happens in my test. After reading the 
source code, I found that this part was rolled back by #3160.
    If I understand correctly, this change is not as expected
    
    ### Changes
    
    Flush start time is moved to after lock again.
    
    (cherry picked from commit c97b57635bb65551ebf149ba458a73a056129bb9)
---
 .../bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java    | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 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 f8ffcb9ee9..1777e2e1c1 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
@@ -701,10 +701,17 @@ public class SingleDirectoryDbLedgerStorage implements 
CompactableLedgerStorage
             return;
         }
 
-        long startTime = MathUtils.nowInNano();
-
         // Only a single flush operation can happen at a time
         flushMutex.lock();
+        long startTime = -1;
+        try {
+            startTime = MathUtils.nowInNano();
+        } catch (Throwable e) {
+            // Fix spotbugs warning. Should never happen
+            flushMutex.unlock();
+            throw new IOException(e);
+        }
+
         try {
             if (writeCache.isEmpty()) {
                 return;

Reply via email to