From b1e749dab9b9cd83a3e84de1525d2a9c4188424d Mon Sep 17 00:00:00 2001 From: Martin Boehm Date: Sun, 26 Aug 2018 21:29:10 +0200 Subject: [PATCH] Add logging of memory status --- blockbook.go | 6 ++++++ db/sync.go | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/blockbook.go b/blockbook.go index b5b99552..f3f91b31 100644 --- a/blockbook.go +++ b/blockbook.go @@ -431,6 +431,8 @@ func storeInternalStateLoop() { lastCompute := time.Now() // randomize the duration between ComputeInternalStateColumnStats to avoid peaks after reboot of machine with multiple blockbooks computePeriod := 9*time.Hour + time.Duration(rand.Float64()*float64((2*time.Hour).Nanoseconds())) + lastLogMemory := time.Now() + logMemoryPeriod := 15 * time.Minute glog.Info("storeInternalStateLoop starting with db stats recompute period ", computePeriod) tickAndDebounce(storeInternalStatePeriodMs*time.Millisecond, (storeInternalStatePeriodMs-1)*time.Millisecond, chanStoreInternalState, func() { if !computeRunning && lastCompute.Add(computePeriod).Before(time.Now()) { @@ -447,6 +449,10 @@ func storeInternalStateLoop() { if err := index.StoreInternalState(internalState); err != nil { glog.Error("storeInternalStateLoop ", errors.ErrorStack(err)) } + if lastLogMemory.Add(logMemoryPeriod).Before(time.Now()) { + glog.Info(index.GetMemoryStats()) + lastLogMemory = time.Now() + } }) glog.Info("storeInternalStateLoop stopped") } diff --git a/db/sync.go b/db/sync.go index 8f52e589..6d5fd713 100644 --- a/db/sync.go +++ b/db/sync.go @@ -308,7 +308,8 @@ ConnectLoop: } if msTime.Before(time.Now()) { glog.Info(w.db.GetMemoryStats()) - msTime = time.Now().Add(1 * time.Minute) + w.metrics.IndexDBSize.Set(float64(w.db.DatabaseSizeOnDisk())) + msTime = time.Now().Add(10 * time.Minute) } h++ }