|
@@ -355,19 +355,7 @@ func (s *store) Restore(b backend.Backend) error {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (s *store) restore() error {
|
|
func (s *store) restore() error {
|
|
|
- b := s.b
|
|
|
|
|
- reportDbTotalSizeInBytesMu.Lock()
|
|
|
|
|
- reportDbTotalSizeInBytes = func() float64 { return float64(b.Size()) }
|
|
|
|
|
- reportDbTotalSizeInBytesMu.Unlock()
|
|
|
|
|
- reportDbTotalSizeInBytesDebugMu.Lock()
|
|
|
|
|
- reportDbTotalSizeInBytesDebug = func() float64 { return float64(b.Size()) }
|
|
|
|
|
- reportDbTotalSizeInBytesDebugMu.Unlock()
|
|
|
|
|
- reportDbTotalSizeInUseInBytesMu.Lock()
|
|
|
|
|
- reportDbTotalSizeInUseInBytes = func() float64 { return float64(b.SizeInUse()) }
|
|
|
|
|
- reportDbTotalSizeInUseInBytesMu.Unlock()
|
|
|
|
|
- reportDbOpenReadTxNMu.Lock()
|
|
|
|
|
- reportDbOpenReadTxN = func() float64 { return float64(b.OpenReadTxN()) }
|
|
|
|
|
- reportDbOpenReadTxNMu.Unlock()
|
|
|
|
|
|
|
+ s.setupMetricsReporter()
|
|
|
|
|
|
|
|
min, max := newRevBytes(), newRevBytes()
|
|
min, max := newRevBytes(), newRevBytes()
|
|
|
revToBytes(revision{main: 1}, min)
|
|
revToBytes(revision{main: 1}, min)
|
|
@@ -579,6 +567,36 @@ func (s *store) ConsistentIndex() uint64 {
|
|
|
return v
|
|
return v
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func (s *store) setupMetricsReporter() {
|
|
|
|
|
+ b := s.b
|
|
|
|
|
+ reportDbTotalSizeInBytesMu.Lock()
|
|
|
|
|
+ reportDbTotalSizeInBytes = func() float64 { return float64(b.Size()) }
|
|
|
|
|
+ reportDbTotalSizeInBytesMu.Unlock()
|
|
|
|
|
+ reportDbTotalSizeInBytesDebugMu.Lock()
|
|
|
|
|
+ reportDbTotalSizeInBytesDebug = func() float64 { return float64(b.Size()) }
|
|
|
|
|
+ reportDbTotalSizeInBytesDebugMu.Unlock()
|
|
|
|
|
+ reportDbTotalSizeInUseInBytesMu.Lock()
|
|
|
|
|
+ reportDbTotalSizeInUseInBytes = func() float64 { return float64(b.SizeInUse()) }
|
|
|
|
|
+ reportDbTotalSizeInUseInBytesMu.Unlock()
|
|
|
|
|
+ reportDbOpenReadTxNMu.Lock()
|
|
|
|
|
+ reportDbOpenReadTxN = func() float64 { return float64(b.OpenReadTxN()) }
|
|
|
|
|
+ reportDbOpenReadTxNMu.Unlock()
|
|
|
|
|
+ reportCurrentRevMu.Lock()
|
|
|
|
|
+ reportCurrentRev = func() float64 {
|
|
|
|
|
+ s.revMu.RLock()
|
|
|
|
|
+ defer s.revMu.RUnlock()
|
|
|
|
|
+ return float64(s.currentRev)
|
|
|
|
|
+ }
|
|
|
|
|
+ reportCurrentRevMu.Unlock()
|
|
|
|
|
+ reportCompactRevMu.Lock()
|
|
|
|
|
+ reportCompactRev = func() float64 {
|
|
|
|
|
+ s.revMu.RLock()
|
|
|
|
|
+ defer s.revMu.RUnlock()
|
|
|
|
|
+ return float64(s.compactMainRev)
|
|
|
|
|
+ }
|
|
|
|
|
+ reportCompactRevMu.Unlock()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// appendMarkTombstone appends tombstone mark to normal revision bytes.
|
|
// appendMarkTombstone appends tombstone mark to normal revision bytes.
|
|
|
func appendMarkTombstone(lg *zap.Logger, b []byte) []byte {
|
|
func appendMarkTombstone(lg *zap.Logger, b []byte) []byte {
|
|
|
if len(b) != revBytesLen {
|
|
if len(b) != revBytesLen {
|