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

chenhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new c97b57635b Flush time started moved to after lock (#3570)
c97b57635b is described below

commit c97b57635bb65551ebf149ba458a73a056129bb9
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.
---
 .../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 f450906de5..d330ea0366 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
@@ -719,10 +719,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