【 TiDB 使用环境】生产环境
【 TiDB 版本】7.5.0
【复现路径】做过哪些操作出现的问题
SELECT * FROM INFORMATION_SCHEMA.CLUSTER_PROCESSLIST WHERE time > 300;
【遇到的问题:问题现象及影响】
查询线程执行时间大于300ms的记录,结果发现有一个SQL执行时间很长,占用内存17个G,不知道是不是在看板查询告警或者其他页面时候出现的,并执行KILL语句也杀不掉,最终导致TIDB不稳定,经常出现中断。
SQL如下:
SELECT FLOOR(UNIX_TIMESTAMP(MIN(summary_begin_time))) AS agg_begin_time, FLOOR(UNIX_TIMESTAMP(MAX(summary_end_time))) AS agg_end_time, ANY_VALUE(digest_text) AS agg_digest_text, ANY_VALUE(digest) AS agg_digest, SUM(exec_count) AS agg_exec_count, SUM(sum_latency) AS agg_sum_latency, MAX(max_latency) AS agg_max_latency, MIN(min_latency) AS agg_min_latency, CAST(SUM(exec_count * avg_latency) / SUM(exec_count) AS SIGNED) AS agg_avg_latency, ANY_VALUE(schema_name) AS agg_schema_name, COUNT(DISTINCT plan_digest) AS agg_plan_count FROM INFORMATION_SCHEMA
.CLUSTER_STATEMENTS_SUMMARY_HISTORY
WHERE summary_begin_time <= FROM_UNIXTIME(?) AND summary_end_time >= FROM_UNIXTIME(?) GROUP BY schema_name, digest ORDER BY agg_sum_latency DESC