From e19e3cafe348787cd65a23984484348a5332b097 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Wed, 2 Aug 2023 17:12:54 +0800 Subject: [PATCH 1/2] statistics: kill in time when to run topnStatsMergeWorker and remove useless Signed-off-by: Weizhen Wang --- statistics/merge_worker.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/statistics/merge_worker.go b/statistics/merge_worker.go index cfba1ba71bf81..1664f693bc8db 100644 --- a/statistics/merge_worker.go +++ b/statistics/merge_worker.go @@ -100,15 +100,7 @@ func (worker *topnStatsMergeWorker) Run(timeZone *time.Location, isIndex bool, } partNum := len(allTopNs) checkNum := len(checkTopNs) - topNsNum := make([]int, checkNum) removeVals := make([][]TopNMeta, partNum) - for i, topN := range checkTopNs { - if topN == nil { - topNsNum[i] = 0 - continue - } - topNsNum[i] = len(topN.TopN) - } // Different TopN structures may hold the same value, we have to merge them. counter := make(map[hack.MutableString]float64) // datumMap is used to store the mapping from the string type to datum type. @@ -136,6 +128,11 @@ func (worker *topnStatsMergeWorker) Run(timeZone *time.Location, isIndex bool, // 1. Check the topN first. // 2. If the topN doesn't contain the value corresponding to encodedVal. We should check the histogram. for j := 0; j < partNum; j++ { + if atomic.LoadUint32(worker.killed) == 1 { + resp.Err = errors.Trace(ErrQueryInterrupted) + worker.respCh <- resp + return + } if (j == i && version >= 2) || allTopNs[j].findTopN(val.Encoded) != -1 { continue } From 6adb4f8cad0b64819b46a2762aaa2dd99664aa9c Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Wed, 2 Aug 2023 17:13:06 +0800 Subject: [PATCH 2/2] statistics: kill in time when to run topnStatsMergeWorker and remove useless Signed-off-by: Weizhen Wang --- statistics/merge_worker.go | 1 - 1 file changed, 1 deletion(-) diff --git a/statistics/merge_worker.go b/statistics/merge_worker.go index 1664f693bc8db..e554da5370453 100644 --- a/statistics/merge_worker.go +++ b/statistics/merge_worker.go @@ -99,7 +99,6 @@ func (worker *topnStatsMergeWorker) Run(timeZone *time.Location, isIndex bool, return } partNum := len(allTopNs) - checkNum := len(checkTopNs) removeVals := make([][]TopNMeta, partNum) // Different TopN structures may hold the same value, we have to merge them. counter := make(map[hack.MutableString]float64)