From 1c1ec56e874914d5323cb68413dfc6a59b9c1cf4 Mon Sep 17 00:00:00 2001 From: Xiaofan Hu Date: Mon, 8 Nov 2021 11:24:52 +0100 Subject: [PATCH] rebalance: use -metrics-per-second for reset Before this change, if go-carbon health check is enabled, when go-carbon cache.size overflows, buckytools reset sync speed to 1 metrics-per-second and there is no way to adjust it. This is not ideal if a go-carbon box always has cache.size limit over the safty threshold due to file system fragmentation or aging ssd. With this change, it allows to have an adjustable minimum sync speed. --- buckytools.go | 2 +- cmd/bucky/common_sync.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/buckytools.go b/buckytools.go index 6d1c5d48..e564b194 100644 --- a/buckytools.go +++ b/buckytools.go @@ -2,7 +2,7 @@ package buckytools const ( // Buckytools suite version - Version = "0.4.2" + Version = "0.5.2" ) // SupportedHashTypes is the string identifiers of the hashing algorithms diff --git a/cmd/bucky/common_sync.go b/cmd/bucky/common_sync.go index 0d8867f7..08ea5a0c 100644 --- a/cmd/bucky/common_sync.go +++ b/cmd/bucky/common_sync.go @@ -492,11 +492,11 @@ func (ms *metricSyncer) newGoCarbonState(addr string, speedUpInterval int) *goCa for { select { case <-state.fastReset: - atomic.StoreInt64(&state.metricsPerSecond, 1) + atomic.StoreInt64(&state.metricsPerSecond, mps) speed.Reset(time.Second / time.Duration(state.metricsPerSecond)) case <-speedUp.C: if ms.isGoCarbonOverload(state) { // overload check - atomic.StoreInt64(&state.metricsPerSecond, 1) + atomic.StoreInt64(&state.metricsPerSecond, mps) } else if !ms.flags.noRandomEasing && atomic.LoadInt64(&state.metricsPerSecond) >= 30 && rand.Intn(10) <= 2 { // random easing