dlg99 commented on code in PR #4307:
URL: https://github.com/apache/bookkeeper/pull/4307#discussion_r1619621006


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java:
##########
@@ -207,10 +209,17 @@ public SingleDirectoryDbLedgerStorage(ServerConfiguration 
conf, LedgerManager le
         gcThread = new GarbageCollectorThread(conf,
                 ledgerManager, ledgerDirsManager, this, entryLogger, 
ledgerIndexDirStatsLogger);
 
+        // Because the writeCache and the writeCacheBeingFlushed are swapped 
during flushes, it is
+        // safer to acquire the underlying cache size and count references and 
then use those for metrics.
+        final AtomicLong finalWriteCacheSize = writeCache.cacheSize;
+        final AtomicLong finalWriteCacheBeingFlushedSize = 
writeCacheBeingFlushed.cacheSize;
+        final LongAdder finalWriteCacheCounter = writeCache.cacheCount;
+        final LongAdder finalWriteCacheBeingFlushedCounter = 
writeCacheBeingFlushed.cacheCount;
+

Review Comment:
   I don't think this is right.
   Lambdas in the DbLedgerStorageStats() constructor used to provide a way to 
access to metrics of current writeCache/.. instance.
   With this change it will provide metrics for the first used instance, one 
before the very first swap, so the stats will stop changing after the cache 
swaps couple of times. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to