From e45584a9b7e78b50c35c19f42ab2b2bfed2b8ff1 Mon Sep 17 00:00:00 2001 From: crazycs Date: Thu, 27 Feb 2020 10:30:13 +0800 Subject: [PATCH] executor: fix threshold check without group by bug (#14961) Signed-off-by: crazycs --- executor/inspection_result.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/executor/inspection_result.go b/executor/inspection_result.go index a1a5db2f7a..dc1e6208f2 100644 --- a/executor/inspection_result.go +++ b/executor/inspection_result.go @@ -682,11 +682,12 @@ func (c compareStoreStatus) genSQL(timeRange plannercore.QueryTimeRange) string t2.time>='%[1]s' and t2.time<='%[2]s'`, timeRange.From.Format(plannercore.MetricTableTimeFormat), timeRange.To.Format(plannercore.MetricTableTimeFormat)) return fmt.Sprintf(`select t1.address,t1.value,t2.address,t2.value, - (t1.value-t2.value)/greatest(t1.value,t2.value) as ratio + (t1.value-t2.value)/t1.value as ratio from metrics_schema.pd_scheduler_store_status t1 join metrics_schema.pd_scheduler_store_status t2 - %s and t1.type='%s' and + %s and t1.type='%s' and t1.time = t2.time and t1.type=t2.type and t1.address != t2.address and - (t1.value-t2.value)/t1.value>%v;`, condition, c.tp, c.threshold) + (t1.value-t2.value)/t1.value>%v group by t1.address,t1.value,t2.address,t2.value order by ratio desc`, + condition, c.tp, c.threshold) } func (c compareStoreStatus) genResult(_ string, row chunk.Row) inspectionResult {