From f5187ced715bf352937ef84bb72814cc85a14d4c Mon Sep 17 00:00:00 2001 From: Xiaoguang Sun Date: Sat, 24 Dec 2022 22:48:46 +0800 Subject: [PATCH] Do not run telemetry loops when it's disabled in config Telemetry can not be enabled by global variable when it's disabled in config file. Therefore we don't need to run telemetry related loops at all when telemetry is disable from global config. Signed-off-by: Xiaoguang Sun --- session/session.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/session/session.go b/session/session.go index d358d761560e2..dc3a308f728db 100644 --- a/session/session.go +++ b/session/session.go @@ -3373,10 +3373,14 @@ func BootstrapSession(store kv.Storage) (*domain.Domain, error) { if dom.GetEtcdClient() != nil { // We only want telemetry data in production-like clusters. When TiDB is deployed over other engines, // for example, unistore engine (used for local tests), we just skip it. Its etcd client is nil. - go func() { - dom.TelemetryReportLoop(ses[5]) - dom.TelemetryRotateSubWindowLoop(ses[5]) - }() + if config.GetGlobalConfig().EnableTelemetry { + // There is no way to turn telemetry on with global variable `tidb_enable_telemetry` + // when it is disabled in config. See IsTelemetryEnabled function in telemetry/telemetry.go + go func() { + dom.TelemetryReportLoop(ses[5]) + dom.TelemetryRotateSubWindowLoop(ses[5]) + }() + } } planReplayerWorkerCnt := config.GetGlobalConfig().Performance.PlanReplayerDumpWorkerConcurrency