From c0fffb8b89515221578ca6168f9d84638657130b Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sun, 19 Nov 2023 16:02:59 +0800 Subject: [PATCH 1/2] domain: randomly trigger the DumpStatsDeltaToKV Signed-off-by: Weizhen Wang --- pkg/domain/domain.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/domain/domain.go b/pkg/domain/domain.go index 050a6c46aa650..e12d0c200617e 100644 --- a/pkg/domain/domain.go +++ b/pkg/domain/domain.go @@ -2407,7 +2407,8 @@ func (do *Domain) updateStatsWorker(ctx sessionctx.Context, owner owner.Manager) defer util.Recover(metrics.LabelDomain, "updateStatsWorker", nil, false) logutil.BgLogger().Info("updateStatsWorker started.") lease := do.statsLease - deltaUpdateTicker := time.NewTicker(20 * lease) + randDuration := time.Duration(rand.Int63n(int64(time.Minute))) + deltaUpdateTicker := time.NewTicker(20*lease + randDuration) gcStatsTicker := time.NewTicker(100 * lease) dumpColStatsUsageTicker := time.NewTicker(100 * lease) readMemTricker := time.NewTicker(memory.ReadMemInterval) From 1acb52502a482bf55f4db0c878e5bae83b85df78 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Mon, 20 Nov 2023 09:24:24 +0800 Subject: [PATCH 2/2] update Signed-off-by: Weizhen Wang --- pkg/domain/domain.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/domain/domain.go b/pkg/domain/domain.go index e12d0c200617e..60e5cc444ac16 100644 --- a/pkg/domain/domain.go +++ b/pkg/domain/domain.go @@ -2407,6 +2407,7 @@ func (do *Domain) updateStatsWorker(ctx sessionctx.Context, owner owner.Manager) defer util.Recover(metrics.LabelDomain, "updateStatsWorker", nil, false) logutil.BgLogger().Info("updateStatsWorker started.") lease := do.statsLease + // We need to have different nodes trigger tasks at different times to avoid the herd effect. randDuration := time.Duration(rand.Int63n(int64(time.Minute))) deltaUpdateTicker := time.NewTicker(20*lease + randDuration) gcStatsTicker := time.NewTicker(100 * lease)