RUNAWAY_WATCHES

RUNAWAY_WATCHES 表展示资源消耗超出预期的查询 Runaway Queries 监控列表,见 Runaway Queries

USE INFORMATION_SCHEMA; DESC RUNAWAY_WATCHES;
+---------------------+--------------+------+------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------------+--------------+------+------+---------+-------+ | ID | bigint(64) | NO | | NULL | | | RESOURCE_GROUP_NAME | varchar(32) | NO | | NULL | | | START_TIME | varchar(32) | NO | | NULL | | | END_TIME | varchar(32) | YES | | NULL | | | WATCH | varchar(12) | NO | | NULL | | | WATCH_TEXT | text | NO | | NULL | | | SOURCE | varchar(128) | NO | | NULL | | | ACTION | varchar(12) | NO | | NULL | | | RULE | varchar(128) | NO | | NULL | | +---------------------+--------------+------+------+---------+-------+ 9 rows in set (0.00 sec)

示例

查询 Runaway Queries 识别名单:

SELECT * FROM INFORMATION_SCHEMA.RUNAWAY_WATCHES ORDER BY id\G

输出结果如下:

*************************** 1. row *************************** ID: 1 RESOURCE_GROUP_NAME: default START_TIME: 2024-09-11 07:20:48 END_TIME: 2024-09-11 07:30:48 WATCH: Exact WATCH_TEXT: select count(*) from `tpch1`.`supplier` SOURCE: 127.0.0.1:4000 ACTION: Kill RULE: ProcessedKeys = 10000(100) *************************** 2. row *************************** ID: 2 RESOURCE_GROUP_NAME: default START_TIME: 2024-09-11 07:20:51 END_TIME: 2024-09-11 07:30:51 WATCH: Exact WATCH_TEXT: select count(*) from `tpch1`.`partsupp` SOURCE: 127.0.0.1:4000 ACTION: Kill RULE: RequestUnit = RRU:143.369959, WRU:0.000000, WaitDuration:0s(10) *************************** 3. row *************************** ID: 3 RESOURCE_GROUP_NAME: default START_TIME: 2024-09-11 07:21:16 END_TIME: 2024-09-11 07:31:16 WATCH: Exact WATCH_TEXT: select sleep(2) from t SOURCE: 127.0.0.1:4000 ACTION: Kill RULE: ElapsedTime = 2024-09-11T15:21:16+08:00(2024-09-11T15:21:16+08:00) 3 rows in set (0.00 sec)

添加一个识别项到资源组 rg1

QUERY WATCH ADD RESOURCE GROUP rg1 SQL TEXT EXACT TO 'select * from sbtest.sbtest1';

再次查询 Runaway Queries 识别名单:

SELECT * FROM INFORMATION_SCHEMA.RUNAWAY_WATCHES\G

输出结果如下:

*************************** 1. row *************************** ID: 1 RESOURCE_GROUP_NAME: default START_TIME: 2024-09-11 07:20:48 END_TIME: 2024-09-11 07:30:48 WATCH: Exact WATCH_TEXT: select count(*) from `tpch1`.`supplier` SOURCE: 127.0.0.1:4000 ACTION: Kill RULE: ProcessedKeys = 10000(100) *************************** 2. row *************************** ID: 2 RESOURCE_GROUP_NAME: default START_TIME: 2024-09-11 07:20:51 END_TIME: 2024-09-11 07:30:51 WATCH: Exact WATCH_TEXT: select count(*) from `tpch1`.`partsupp` SOURCE: 127.0.0.1:4000 ACTION: Kill RULE: RequestUnit = RRU:143.369959, WRU:0.000000, WaitDuration:0s(10) *************************** 3. row *************************** ID: 3 RESOURCE_GROUP_NAME: default START_TIME: 2024-09-11 07:21:16 END_TIME: 2024-09-11 07:31:16 WATCH: Exact WATCH_TEXT: select sleep(2) from t SOURCE: 127.0.0.1:4000 ACTION: Kill RULE: ElapsedTime = 2024-09-11T15:21:16+08:00(2024-09-11T15:21:16+08:00) *************************** 4. row *************************** ID: 4 RESOURCE_GROUP_NAME: default START_TIME: 2024-09-11 07:23:10 END_TIME: UNLIMITED WATCH: Exact WATCH_TEXT: select * from sbtest.sbtest1 SOURCE: manual ACTION: Kill RULE: None 3 row in set (0.00 sec)

RUNAWAY_WATCHES 表中列的含义如下:

  • ID:识别项 ID。
  • RESOURCE_GROUP_NAME:资源组名称。
  • START_TIME:开始时间。
  • END_TIME:结束时间。UNLIMITED 表示识别项的有效时间无限长。
  • WATCH:识别匹配类型,其值如下:
    • Plan 表示按照 Plan Digest 匹配,此时列 WATCH_TEXT 显示 Plan Digest。
    • Similar 表示按照 SQL Digest 匹配,此时列 WATCH_TEXT 显示 SQL Digest。
    • Exact 表示按照 SQL 文本匹配,此时列 WATCH_TEXT 显示 SQL 文本。
  • SOURCE:识别项来源,如果是被 QUERY_LIMIT 规则识别,则显示识别到的 TiDB IP;如果是手动添加,则显示 manual
  • ACTION:识别后的对应操作。
  • RULE:识别规则。目前包括 ElapsedTimeProcessedKeysRequestUnit 这三种规则。格式为 ProcessedKeys = 666(10),其中 666 为实际值,10 为阈值。

文档内容是否有帮助?