RUNAWAY_WATCHES

The RUNAWAY_WATCHES table shows the watch list of runaway queries that consume more resources than expected. For more information, see Runaway Queries.

RUNAWAY_WATCHES - 图1

Note

This table is not available on TiDB Serverless clusters.

  1. USE INFORMATION_SCHEMA;
  2. DESC RUNAWAY_WATCHES;
  1. +---------------------+--------------+------+------+---------+-------+
  2. | Field | Type | Null | Key | Default | Extra |
  3. +---------------------+--------------+------+------+---------+-------+
  4. | ID | bigint(64) | NO | | NULL | |
  5. | RESOURCE_GROUP_NAME | varchar(32) | NO | | NULL | |
  6. | START_TIME | varchar(32) | NO | | NULL | |
  7. | END_TIME | varchar(32) | YES | | NULL | |
  8. | WATCH | varchar(12) | NO | | NULL | |
  9. | WATCH_TEXT | text | NO | | NULL | |
  10. | SOURCE | varchar(128) | NO | | NULL | |
  11. | ACTION | varchar(12) | NO | | NULL | |
  12. +---------------------+--------------+------+------+---------+-------+
  13. 8 rows in set (0.00 sec)

Examples

Query the watch list of runaway queries:

  1. SELECT * FROM INFORMATION_SCHEMA.RUNAWAY_WATCHES\G

The output is as follows:

  1. *************************** 1. row ***************************
  2. ID: 20003
  3. RESOURCE_GROUP_NAME: rg2
  4. START_TIME: 2023-07-28 13:06:08
  5. END_TIME: UNLIMITED
  6. WATCH: Similar
  7. WATCH_TEXT: 5b7fd445c5756a16f910192ad449c02348656a5e9d2aa61615e6049afbc4a82e
  8. SOURCE: 127.0.0.1:4000
  9. ACTION: Kill
  10. *************************** 2. row ***************************
  11. ID: 16004
  12. RESOURCE_GROUP_NAME: rg2
  13. START_TIME: 2023-07-28 01:45:30
  14. END_TIME: UNLIMITED
  15. WATCH: Similar
  16. WATCH_TEXT: 3d48fca401d8cbb31a9f29adc9c0f9d4be967ca80a34f59c15f73af94e000c84
  17. SOURCE: 127.0.0.1:4000
  18. ACTION: Kill
  19. 2 rows in set (0.00 sec)

Add a watch item into list to the resource group rg1:

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

Query the watch list of runaway queries again:

  1. SELECT * FROM INFORMATION_SCHEMA.RUNAWAY_WATCHES\G

The output is as follows:

  1. *************************** 1. row ***************************
  2. ID: 20003
  3. RESOURCE_GROUP_NAME: rg2
  4. START_TIME: 2023-07-28 13:06:08
  5. END_TIME: UNLIMITED
  6. WATCH: Similar
  7. WATCH_TEXT: 5b7fd445c5756a16f910192ad449c02348656a5e9d2aa61615e6049afbc4a82e
  8. SOURCE: 127.0.0.1:4000
  9. ACTION: Kill
  10. *************************** 2. row ***************************
  11. ID: 16004
  12. RESOURCE_GROUP_NAME: rg2
  13. START_TIME: 2023-07-28 01:45:30
  14. END_TIME: UNLIMITED
  15. WATCH: Similar
  16. WATCH_TEXT: 3d48fca401d8cbb31a9f29adc9c0f9d4be967ca80a34f59c15f73af94e000c84
  17. SOURCE: 127.0.0.1:4000
  18. ACTION: Kill
  19. *************************** 3. row ***************************
  20. ID: 20004
  21. RESOURCE_GROUP_NAME: rg1
  22. START_TIME: 2023-07-28 14:23:04
  23. END_TIME: UNLIMITED
  24. WATCH: Exact
  25. WATCH_TEXT: select * from sbtest.sbtest1
  26. SOURCE: manual
  27. ACTION: NoneAction
  28. 3 row in set (0.00 sec)

The meaning of each column field in the RUNAWAY_WATCHES table is as follows:

  • ID: the ID of the watch item.
  • RESOURCE_GROUP_NAME: the name of the resource group.
  • START_TIME: the start time.
  • END_TIME: the end time. UNLIMITED means that the watch item has an unlimited validity period.
  • WATCH: the match type of the quick identification. The values are as follows:
    • Plan indicates that the Plan Digest is matched. In this case, the WATCH_TEXT column shows the Plan Digest.
    • Similar indicates that the SQL Digest is matched. In this case, the WATCH_TEXT column shows the SQL Digest.
    • Exact indicates that the SQL text is matched. In this case, the WATCH_TEXT column shows the SQL text.
  • SOURCE: the source of the watch item. If it is identified by the QUERY_LIMIT rule, the identified TiDB IP address is displayed. If it is manually added, manual is displayed.
  • ACTION: the corresponding operation after the identification.