From 88b9972d379af802b652ff85b9b2d23894585c67 Mon Sep 17 00:00:00 2001 From: Chengyu Liu Date: Wed, 7 Feb 2024 11:28:05 +0800 Subject: [PATCH] fix: codis-dashboard uses 100% cpu(#2332) (#2393) Co-authored-by: liuchengyu --- codis/pkg/proxy/stats.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/codis/pkg/proxy/stats.go b/codis/pkg/proxy/stats.go index 06a2b67aa2..e157e31270 100644 --- a/codis/pkg/proxy/stats.go +++ b/codis/pkg/proxy/stats.go @@ -85,7 +85,13 @@ func init() { // Clear the accumulated maximum delay to 0 go func() { for { - time.Sleep(time.Duration(RefreshPeriod.Int64())) + refreshPeriod := RefreshPeriod.Int64() + if refreshPeriod == 0 { + time.Sleep(15 * time.Second) + } else { + time.Sleep(time.Duration(refreshPeriod)) + } + for _, s := range cmdstats.opmap { s.maxDelay.Set(0) }