bookkeeper
bookkeeper copied to clipboard
Prevent race in SingleDirectoryDbLedgerStorage metrics collection
Motivation
We swap the writeCache and the writeCacheBeingFlushed on flush. Therefore, it is not safe to call each to get the size/count metrics. Instead, if we expose the underlying accumulators, we can safely get the stats.
Changes
Expose the AtomicLong and the LongAdder objects in the WriteCache for safer metrics reporting.
How do you guarantee they won't swap during L214-L217? It seems problem is not solved.
How do you guarantee they won't swap during L214-L217? It seems problem is not solved.
We're in the constructor. I don't think anything could have access to trigger the swap yet.