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 | |
+---------------------+--------------+------+------+---------+-------+
8 rows in set (0.00 sec)
示例
查询 Runaway Queries 识别名单:
SELECT * FROM INFORMATION_SCHEMA.RUNAWAY_WATCHES\G;
输出结果如下:
*************************** 1. row ***************************
ID: 20003
RESOURCE_GROUP_NAME: rg2
START_TIME: 2023-07-28 13:06:08
END_TIME: UNLIMITED
WATCH: Similar
WATCH_TEXT: 5b7fd445c5756a16f910192ad449c02348656a5e9d2aa61615e6049afbc4a82e
SOURCE: 127.0.0.1:4000
ACTION: Kill
*************************** 2. row ***************************
ID: 16004
RESOURCE_GROUP_NAME: rg2
START_TIME: 2023-07-28 01:45:30
END_TIME: UNLIMITED
WATCH: Similar
WATCH_TEXT: 3d48fca401d8cbb31a9f29adc9c0f9d4be967ca80a34f59c15f73af94e000c84
SOURCE: 127.0.0.1:4000
ACTION: Kill
2 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: 20003
RESOURCE_GROUP_NAME: rg2
START_TIME: 2023-07-28 13:06:08
END_TIME: UNLIMITED
WATCH: Similar
WATCH_TEXT: 5b7fd445c5756a16f910192ad449c02348656a5e9d2aa61615e6049afbc4a82e
SOURCE: 127.0.0.1:4000
ACTION: Kill
*************************** 2. row ***************************
ID: 16004
RESOURCE_GROUP_NAME: rg2
START_TIME: 2023-07-28 01:45:30
END_TIME: UNLIMITED
WATCH: Similar
WATCH_TEXT: 3d48fca401d8cbb31a9f29adc9c0f9d4be967ca80a34f59c15f73af94e000c84
SOURCE: 127.0.0.1:4000
ACTION: Kill
*************************** 3. row ***************************
ID: 20004
RESOURCE_GROUP_NAME: rg1
START_TIME: 2023-07-28 14:23:04
END_TIME: UNLIMITED
WATCH: Exact
WATCH_TEXT: select * from sbtest.sbtest1
SOURCE: manual
ACTION: NoneAction
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
:识别后的对应操作。