From bee9915eee978057581cec3e928ef41faadf4b71 Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Fri, 11 Nov 2022 18:31:53 +0800 Subject: [PATCH] util: add lock for MergeBasicStats (#38998) (#39040) close pingcap/tidb#38994 --- util/execdetails/execdetails.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/execdetails/execdetails.go b/util/execdetails/execdetails.go index 4c0670e93eb97..2c7103a7901fb 100644 --- a/util/execdetails/execdetails.go +++ b/util/execdetails/execdetails.go @@ -396,6 +396,8 @@ func (crs *CopRuntimeStats) GetActRows() (totalRows int64) { // MergeBasicStats traverses basicCopRuntimeStats in the CopRuntimeStats and collects some useful information. func (crs *CopRuntimeStats) MergeBasicStats() (procTimes []time.Duration, totalTime time.Duration, totalTasks, totalLoops, totalThreads int32) { + crs.Lock() + defer crs.Unlock() procTimes = make([]time.Duration, 0, 32) for _, instanceStats := range crs.stats { for _, stat := range instanceStats {