Removing the specified runaway does not take effect

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: remove掉指定的runaway不生效

| username: 人如其名

Bug Report
Clearly and accurately describe the issue you found. Providing any possible steps to reproduce the issue will help the development team address it promptly.
[TiDB Version] 8.0.11-TiDB-v8.1.0
[Impact of the Bug] query watch remove <runaway_id> is not effective

[Possible Steps to Reproduce the Issue]

ALTER RESOURCE GROUP default QUERY_LIMIT=(EXEC_ELAPSED='1h', ACTION=KILL, WATCH=PLAN DURATION='10m');
QUERY WATCH ADD RESOURCE GROUP rg1 SQL DIGEST '299bb8320165dc1a1ab39861d5ed2826189ba7e30c3eb3aceace6ac7a4b78354';
SELECT * FROM INFORMATION_SCHEMA.RUNAWAY_WATCHES ORDER BY id;
query watch remove <id>;

As shown in the image above, query watch remove 30005 failed to remove the runaway_watch with ID 30005, and a restart is required to clear all RUNAWAY_WATCHES.

| username: ziptoam | Original post link

The query monitoring feature (Query Watch) of TiDB is not working as expected, specifically the query watch remove command cannot successfully remove the specified monitoring item.

| username: nolouch-PingCAP | Original post link

I couldn’t reproduce it successfully. Do you still have the TiDB logs from that time?

| username: 人如其名 | Original post link

I upgraded from 7.5.1, and it happens every time. As follows:

ALTER RESOURCE GROUP default QUERY_LIMIT=(EXEC_ELAPSED='1h', ACTION=KILL,  WATCH=PLAN DURATION='10m');
QUERY WATCH ADD RESOURCE GROUP default SQL text SIMILAR to 'select count(*) from tpch1.customer';
SELECT * FROM INFORMATION_SCHEMA.RUNAWAY_WATCHES ORDER BY id;
query watch remove <id>;
SELECT * FROM INFORMATION_SCHEMA.RUNAWAY_WATCHES ORDER BY id;

Due to the relatively small amount of logs, I will paste them directly here (the tidb-server was cleaned and restarted before the above steps):

[tidb@localhost log]$ cat tidb.log
[2024/06/17 20:32:01.531 +08:00] [INFO] [meminfo.go:196] ["use physical memory hook"] [cgroupMemorySize=9223372036854771712] [physicalMemorySize=67240763392]
[2024/06/17 20:32:01.532 +08:00] [INFO] [cpuprofile.go:113] ["parallel cpu profiler started"]
[2024/06/17 20:32:01.532 +08:00] [INFO] [cgmon.go:60] ["cgroup monitor started"]
[2024/06/17 20:32:01.532 +08:00] [INFO] [printer.go:47] ["Welcome to TiDB."] ["Release Version"=v8.1.0] [Edition=Community] ["Git Commit Hash"=945d07c5d5c7a1ae212f6013adfb187f2de24b23] ["Git Branch"=HEAD] ["UTC Build Time"="2024-05-21 03:51:57"] [GoVersion=go1.21.10] ["Race Enabled"=false] ["Check Table Before Drop"=false]
[2024/06/17 20:32:01.532 +08:00] [INFO] [cgmon.go:130] ["set the maxprocs"] [quota=2]
[2024/06/17 20:32:01.532 +08:00] [INFO] [printer.go:52] ["loaded config"] [config="{\"host\":\"0.0.0.0\",\"advertise-address\":\"192.168.31.201\",\"port\":4000,\"cors\":\"\",\"store\":\"tikv\",\"path\":\"192.168.31.201:2379\",\"socket\":\"/tmp/tidb-4000.sock\",\"lease\":\"45s\",\"split-table\":true,\"token-limit\":1000,\"temp-dir\":\"/data/tidb-data\",\"tmp-storage-path\":\"/data/tidb-data/1000_tidb/MC4wLjAuMDo0MDAwLzAuMC4wLjA6MTAwODA=/tmp-storage\",\"tmp-storage-quota\":-1,\"server-version\":\"\",\"version-comment\":\"\",\"tidb-edition\":\"\",\"tidb-release-version\":\"\",\"keyspace-name\":\"\",\"log\":{\"level\":\"info\",\"format\":\"text\",\"disable-timestamp\":null,\"enable-timestamp\":null,\"disable-error-stack\":null,\"enable-error-stack\":null,\"file\":{\"filename\":\"/data/tidb-deploy/tidb-4000/log/tidb.log\",\"max-size\":300,\"max-days\":0,\"max-backups\":0,\"compression\":\"\"},\"slow-query-file\":\"/data/tidb-deploy/tidb-4000/log/tidb_slow_query.log\",\"expensive-threshold\":10000,\"general-log-file\":\"\",\"query-log-max-len\":4096,\"enable-slow-log\":true,\"slow-threshold\":300,\"record-plan-in-slow-log\":1,\"timeout\":0},\"instance\":{\"tidb_general_log\":false,\"tidb_pprof_sql_cpu\":false,\"ddl_slow_threshold\":300,\"tidb_expensive_query_time_threshold\":60,\"tidb_expensive_txn_time_threshold\":600,\"tidb_stmt_summary_enable_persistent\":false,\"tidb_stmt_summary_filename\":\"tidb-statements.log\",\"tidb_stmt_summary_file_max_days\":3,\"tidb_stmt_summary_file_max_size\":64,\"tidb_stmt_summary_file_max_backups\":0,\"tidb_enable_slow_log\":true,\"tidb_slow_log_threshold\":300,\"tidb_record_plan_in_slow_log\":1,\"tidb_check_mb4_value_in_utf8\":true,\"tidb_force_priority\":\"NO_PRIORITY\",\"tidb_memory_usage_alarm_ratio\":0.8,\"tidb_enable_collect_execution_info\":true,\"plugin_dir\":\"/data/deploy/plugin\",\"plugin_load\":\"\",\"max_connections\":0,\"tidb_enable_ddl\":true,\"tidb_rc_read_check_ts\":false,\"tidb_service_scope\":\"\"},\"security\":{\"skip-grant-table\":false,\"ssl-ca\":\"\",\"ssl-cert\":\"\",\"ssl-key\":\"\",\"cluster-ssl-ca\":\"\",\"cluster-ssl-cert\":\"\",\"cluster-ssl-key\":\"\",\"cluster-verify-cn\":null,\"session-token-signing-cert\":\"\",\"session-token-signing-key\":\"\",\"spilled-file-encryption-method\":\"plaintext\",\"enable-sem\":false,\"auto-tls\":false,\"tls-version\":\"\",\"rsa-key-size\":4096,\"secure-bootstrap\":false,\"auth-token-jwks\":\"\",\"auth-token-refresh-interval\":\"1h0m0s\",\"disconnect-on-expired-password\":true},\"status\":{\"status-host\":\"0.0.0.0\",\"metrics-addr\":\"\",\"status-port\":10080,\"metrics-interval\":15,\"report-status\":true,\"record-db-qps\":false,\"record-db-label\":false,\"grpc-keepalive-time\":10,\"grpc-keepalive-timeout\":3,\"grpc-concurrent-streams\":1024,\"grpc-initial-window-size\":2097152,\"grpc-max-send-msg-size\":2147483647},\"performance\":{\"max-procs\":0,\"max-memory\":0,\"server-memory-quota\":0,\"stats-lease\":\"3s\",\"stmt-count-limit\":5000,\"pseudo-estimate-ratio\":0.8,\"bind-info-lease\":\"3s\",\"txn-entry-size-limit\":6291456,\"txn-total-size-limit\":104857600,\"tcp-keep-alive\":true,\"tcp-no-delay\":true,\"cross-join\":true,\"distinct-agg-push-down\":false,\"projection-push-down\":false,\"max-txn-ttl\":3600000,\"index-usage-sync-lease\":\"\",\"plan-replayer-gc-lease\":\"10m\",\"gogc\":100,\"enforce-mpp\":false,\"stats-load-concurrency\":5,\"stats-load-queue-size\":1000,\"analyze-partition-concurrency-quota\":16,\"plan-replayer-dump-worker-concurrency\":1,\"enable-stats-cache-mem-quota\":true,\"committer-concurrency\":128,\"run-auto-analyze\":true,\"force-priority\":\"NO_PRIORITY\",\"memory-usage-alarm-ratio\":0.8,\"enable-load-fmsketch\":false,\"lite-init-stats\":true,\"force-init-stats\":true,\"concurrently-init-stats\":false},\"prepared-plan-cache\":{\"enabled\":true,\"capacity\":100,\"memory-guard-ratio\":0.1},\"opentracing\":{\"enable\":false,\"rpc-metrics\":false,\"sampler\":{\"type\":\"const\",\"param\":1,\"sampling-server-url\":\"\",\"max-operations\":0,\"sampling-refresh-interval\":0},\"reporter\":{\"queue-size\":0,\"buffer-flush-interval\":0,\"log-spans\":false,\"local-agent-host-port\":\"\"}},\"proxy-protocol\":{\"networks\":\"\",\"header-timeout\":5,\"fallbackable\":false},\"pd-client\":{\"pd-server-timeout\":3},\"tikv-client\":{\"grpc-connection-count\":4,\"grpc-keepalive-time\":10,\"grpc-keepalive-timeout\":3,\"grpc-compression-type\":\"none\",\"grpc-shared-buffer-pool\":false,\"grpc-initial-window-size\":134217728,\"grpc-initial-conn-window-size\":134217728,\"commit-timeout\":\"41s\",\"async-commit\":{\"keys-limit\":256,\"total-key-size-limit\":4096,\"safe-window\":2000000000,\"allowed-clock-drift\":500000000},\"max-batch-size\":128,\"overload-threshold\":200,\"max-batch-wait-time\":0,\"batch-wait-size\":8,\"enable-chunk-rpc\":true,\"region-cache-ttl\":600,\"store-limit\":0,\"store-liveness-timeout\":\"1s\",\"copr-cache\":{\"capacity-mb\":0},\"copr-req-timeout\":60000000000,\"ttl-refreshed-txn-size\":33554432,\"resolve-lock-lite-threshold\":16,\"max-concurrency-request-limit\":9223372036854775807,\"enable-replica-selector-v2\":true},\"binlog\":{\"enable\":false,\"ignore-error\":false,\"write-timeout\":\"15s\",\"binlog-socket\":\"\",\"strategy\":\"range\"},\"compatible-kill-query\":false,\"pessimistic-txn\":{\"max-retry-count\":256,\"deadlock-history-capacity\":10,\"deadlock-history-collect-retryable\":false,\"pessimistic-auto-commit\":false,\"constraint-check-in-place-pessimistic\":true},\"max-index-length\":3072,\"index-limit\":64,\"table-column-count-limit\":1017,\"graceful-wait-before-shutdown\":0,\"alter-primary-key\":false,\"treat-old-version-utf8-as-utf8mb4\":true,\"enable-table-lock\":false,\"delay-clean-table-lock\":0,\"split-region-max-num\":1000,\"top-sql\":{\"receiver-address\":\"\"},\"repair-mode\":false,\"repair-table-list\":[],\"isolation-read\":{\"engines\":[\"tikv\",\"tiflash\",\"tidb\"]},\"new_collations_enabled_on_first_bootstrap\":true,\"experimental\":{\"allow-expression-index\":false},\"skip-register-to-dashboard\":false,\"enable-telemetry\":false,\"labels\":{},\"enable-global-index\":false,\"deprecate-integer-display-length\":false,\"enable-enum-length-limit\":true,\"stores-refresh-interval\":60,\"enable-tcp4-only\":false,\"enable-forwarding\":false,\"max-ballast-object-size\":0,\"ballast-object-size\":0,\"transaction-summary\":{\"transaction-summary-capacity\":500,\"transaction-id-digest-min-duration\":2147483647},\"enable-global-kill\":true,\"enable-32bits-connection-id\":true,\"initialize-sql-file\":\"\",\"enable-batch-dml\":false,\"mem-quota-query\":1073741824,\"oom-action\":\"cancel\",\"oom-use-tmp-storage\":true,\"check-mb4-value-in-utf8\":true,\"enable-collect-execution-info\":true,\"plugin\":{\"dir\":\"/data/deploy/plugin\",\"load\":\"\"},\"max-server-connections\":0,\"run-ddl\":true,\"disaggregated-tiflash\":false,\"autoscaler-type\":\"aws\",\"autoscaler-addr\":\"tiflash-autoscale-lb.tiflash-autoscale.svc.cluster.local:8081\",\"is-tiflashcompute-fixed-pool\":false,\"autoscaler-cluster-id\":\"\",\"use-autoscaler\":false,\"tidb-max-reuse-chunk\":64,\"tidb-max-reuse-column\":256,\"tidb-enable-exit-check\":false,\"in-mem-slow-query-topn-num\":30,\"in-mem-slow-query-recent-num\":500}"]
[2024/06/17 20:32:01.532 +08:00] [INFO] [main.go:467] ["disable Prometheus push client"]
[2024/06/17 20:32:01.532 +08:00] [INFO] [store.go:76] ["new store"] [path=tikv://192.168.31.201:2379]
[2024/06/17 20:32:01.532 +08:00] [INFO] [cgmon.go:154] ["set the memory limit"] [memLimit=67240763392]
[2024/06/17 20:32:01.532 +08:00] [INFO] [systime_mon.go:26] ["start system time monitor"]
[2024/06/17 20:32:01.534 +08:00] [INFO] [pd_service_discovery.go:1016] ["[pd] switch leader"] [new-leader=http://192.168.31.201:2379] [old-leader=]
[2024/06/17 20:32:01.534 +08:00] [INFO] [pd_service_discovery.go:498] ["[pd] init cluster id"] [cluster-id=7375541095005751330]
[2024/06/17 20:32:01.535 +08:00] [INFO] [client.go:613] ["[pd] changing service mode"] [old-mode=UNKNOWN_SVC_MODE] [new-mode=PD_SVC_MODE]
[2024/06/17 20:32:01.535 +08:00] [INFO] [tso_client.go:293] ["[tso] switch dc tso global allocator serving url"] [dc-location=global] [new-url=http://192.168.31.201:2379]
[2024/06/17 20:32:01.535 +08:00] [INFO] [client.go:619] ["[pd] service mode changed"] [old-mode=UNKNOWN_SVC_MODE] [new-mode=PD_SVC_MODE]
[2024/06/17 20:32:01.535 +08:00] [INFO] [tso_dispatcher.go:119] ["[tso] start tso deadline watcher"] [dc-location=global]
[2024/06/17 20:32:01.535 +08:00] [INFO] [tso_dispatcher.go:168] ["[tso] tso dispatcher created"] [dc-location=global]
[2024/06/17 20:32:01.535 +08:00] [INFO] [tso_dispatcher.go:336] ["[tso] start tso connection contexts updater"] [dc-location=global]
[2024/06/17 20:32:01.535 +08:00] [INFO] [tso_client.go:130] ["[tso] start tso dispatcher check loop"]
[2024/06/17 20:32:01.535 +08:00] [INFO] [tikv_driver.go:197] ["using API V1."]
[2024/06/17 20:32:01.536 +08:00] [INFO] [store.go:82] ["new store with retry success"]
[2024/06/17 20:32:01.537 +08:00] [INFO] [store_cache.go:510] ["change store resolve state"] [store=1] [addr=192.168.31.201:20160] [from=unresolved] [to=resolved] [liveness-state=reachable]
[2024/06/17 20:32:01.542 +08:00] [INFO] [tidb.go:80] ["new domain"] [store=tikv-7375541095005751330] ["ddl lease"=45s] ["stats lease"=3s]
[2024/06/17 20:32:01.550 +08:00] [WARN] [info.go:316] ["init TiFlashReplicaManager"]
[2024/06/17 20:32:01.554 +08:00] [INFO] [domain.go:2796] [acquireServerID] [serverID=1287] ["lease id"=6a9b8ffd9bb68972]
[2024/06/17 20:32:01.555 +08:00] [INFO] [controller.go:185] ["load resource controller config"] [config="{\"degraded-mode-wait-duration\":\"0s\",\"ltb-max-wait-duration\":\"30s\",\"wait-retry-interval\":\"50ms\",\"wait-retry-times\":10,\"request-unit\":{\"read-base-cost\":0.125,\"read-per-batch-base-cost\":0.5,\"read-cost-per-byte\":0.0000152587890625,\"write-base-cost\":1,\"write-per-batch-base-cost\":1,\"write-cost-per-byte\":0.0009765625,\"read-cpu-ms-cost\":0.3333333333333333},\"enable-controller-trace-log\":\"false\"}"] [ru-config="{\"ReadBaseCost\":0.125,\"ReadPerBatchBaseCost\":0.5,\"ReadBytesCost\":0.0000152587890625,\"WriteBaseCost\":1,\"WritePerBatchBaseCost\":1,\"WriteBytesCost\":0.0009765625,\"CPUMsCost\":0.3333333333333333,\"LTBMaxWaitDuration\":30000000000,\"WaitRetryInterval\":50000000,\"WaitRetryTimes\":10,\"DegradedModeWaitDuration\":0}"]
[2024/06/17 20:32:01.588 +08:00] [INFO] [domain.go:315] ["full load InfoSchema success"] [currentSchemaVersion=0] [neededSchemaVersion=1204] ["start time"=31.77388ms]
[2024/06/17 20:32:01.589 +08:00] [INFO] [domain.go:635] ["full load and reset schema validator"]
[2024/06/17 20:32:01.589 +08:00] [INFO] [ddl.go:817] ["start DDL"] [category=ddl] [ID=aeb5e4cb-2b2a-4b0c-ac3f-4a8b9437b392] [runWorker=true]
[2024/06/17 20:32:01.589 +08:00] [INFO] [ddl.go:776] ["start delRangeManager OK"] [category=ddl] ["is a emulator"=false]
[2024/06/17 20:32:01.590 +08:00] [INFO] [manager.go:188] ["start campaign owner"] [ownerInfo="[ddl] /tidb/ddl/fg/owner"]
[2024/06/17 20:32:01.591 +08:00] [INFO] [env.go:101] ["the ingest sorted directory"] [category=ddl-ingest] ["data path"=/data/tidb-data/tmp_ddl-4000]
[2024/06/17 20:32:01.591 +08:00] [INFO] [env.go:74] ["init global ingest backend environment finished"] [category=ddl-ingest] ["memory limitation"=33620381696]
| username: 人如其名 | Original post link

I directly installed version 8.1 and retested. If I add a QUERY WATCH, it can be killed, and after executing it a few more times, the issue will reoccur. Once it appears, it cannot be deleted afterward.

| username: 人如其名 | Original post link

I reproduced the issue completely:

1. Load tpch1 data:

tiup bench tpch -H 192.168.31.201 -P 4000 -U root -p123 -D tpch1 prepare --sf=1

2. Modify the default Resource Group:

ALTER RESOURCE GROUP default QUERY_LIMIT=(EXEC_ELAPSED='100ms', ACTION=KILL, WATCH=EXACT DURATION='10m');

3. Execute the concurrent request program (program attached main.go (1.8 KB)):

go run main.go -host 192.168.31.201 -port 4000 -user root -password "123" -database tpch1

4. Observe RUNAWAY_WATCHES and randomly REMOVE one to see if it can be removed:

mysql> SELECT * FROM INFORMATION_SCHEMA.RUNAWAY_WATCHES ORDER BY id desc limit 10;
+-----+---------------------+---------------------+---------------------+-------+---------------------------------------------------------------+---------------------+--------+
| ID  | RESOURCE_GROUP_NAME | START_TIME          | END_TIME            | WATCH | WATCH_TEXT                                                    | SOURCE              | ACTION |
+-----+---------------------+---------------------+---------------------+-------+---------------------------------------------------------------+---------------------+--------+
| 470 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1997-08-13' | 192.168.31.201:4000 | Kill   |
| 469 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1996-02-03' | 192.168.31.201:4000 | Kill   |
| 468 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1996-08-03' | 192.168.31.201:4000 | Kill   |
| 467 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1996-02-26' | 192.168.31.201:4000 | Kill   |
| 466 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1995-07-19' | 192.168.31.201:4000 | Kill   |
| 465 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1994-09-25' | 192.168.31.201:4000 | Kill   |
| 464 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1994-09-18' | 192.168.31.201:4000 | Kill   |
| 463 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1995-03-30' | 192.168.31.201:4000 | Kill   |
| 462 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1994-11-20' | 192.168.31.201:4000 | Kill   |
| 461 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1997-06-29' | 192.168.31.201:4000 | Kill   |
+-----+---------------------+---------------------+---------------------+-------+---------------------------------------------------------------+---------------------+--------+
10 rows in set (0.01 sec)

mysql> query watch remove 461;
Query OK, 0 rows affected (0.01 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.RUNAWAY_WATCHES ORDER BY id desc limit 10;
+-----+---------------------+---------------------+---------------------+-------+---------------------------------------------------------------+---------------------+--------+
| ID  | RESOURCE_GROUP_NAME | START_TIME          | END_TIME            | WATCH | WATCH_TEXT                                                    | SOURCE              | ACTION |
+-----+---------------------+---------------------+---------------------+-------+---------------------------------------------------------------+---------------------+--------+
| 470 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1997-08-13' | 192.168.31.201:4000 | Kill   |
| 469 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1996-02-03' | 192.168.31.201:4000 | Kill   |
| 468 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1996-08-03' | 192.168.31.201:4000 | Kill   |
| 467 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1996-02-26' | 192.168.31.201:4000 | Kill   |
| 466 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1995-07-19' | 192.168.31.201:4000 | Kill   |
| 465 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1994-09-25' | 192.168.31.201:4000 | Kill   |
| 464 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1994-09-18' | 192.168.31.201:4000 | Kill   |
| 463 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1995-03-30' | 192.168.31.201:4000 | Kill   |
| 462 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1994-11-20' | 192.168.31.201:4000 | Kill   |
| 460 | default             | 2024-06-17 22:27:05 | 2024-06-17 22:37:05 | Exact | select  count(*) from orders where o_orderdate = '1993-12-25' | 192.168.31.201:4000 | Kill   |
+-----+---------------------+---------------------+---------------------+-------+---------------------------------------------------------------+---------------------+--------+
10 rows in set (0.00 sec)

Found that REMOVE works without issues.

5. Re-execute the concurrent request program to make RUNAWAY_WATCHES ID exceed 1000 (can run for more than ten seconds and then terminate with ctrl+c):

go run main.go -host 192.168.31.201 -port 4000 -user root -password "123" -database tpch1

6. Remove an ID again:

mysql> SELECT * FROM INFORMATION_SCHEMA.RUNAWAY_WATCHES ORDER BY id desc limit 10;
+------+---------------------+---------------------+---------------------+-------+---------------------------------------------------------------+---------------------+--------+
| ID   | RESOURCE_GROUP_NAME | START_TIME          | END_TIME            | WATCH | WATCH_TEXT                                                    | SOURCE              | ACTION |
+------+---------------------+---------------------+---------------------+-------+---------------------------------------------------------------+---------------------+--------+
| 1310 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1996-09-16' | 192.168.31.201:4000 | Kill   |
| 1309 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1994-08-25' | 192.168.31.201:4000 | Kill   |
| 1308 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1997-12-13' | 192.168.31.201:4000 | Kill   |
| 1307 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1995-08-03' | 192.168.31.201:4000 | Kill   |
| 1306 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1998-07-03' | 192.168.31.201:4000 | Kill   |
| 1305 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1998-05-29' | 192.168.31.201:4000 | Kill   |
| 1304 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1996-02-20' | 192.168.31.201:4000 | Kill   |
| 1303 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1997-12-06' | 192.168.31.201:4000 | Kill   |
| 1302 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1997-03-26' | 192.168.31.201:4000 | Kill   |
| 1301 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1995-08-23' | 192.168.31.201:4000 | Kill   |
+------+---------------------+---------------------+---------------------+-------+---------------------------------------------------------------+---------------------+--------+
10 rows in set (0.01 sec)

mysql> query watch remove 1310;
Query OK, 0 rows affected (0.01 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.RUNAWAY_WATCHES ORDER BY id desc limit 10;
+------+---------------------+---------------------+---------------------+-------+---------------------------------------------------------------+---------------------+--------+
| ID   | RESOURCE_GROUP_NAME | START_TIME          | END_TIME            | WATCH | WATCH_TEXT                                                    | SOURCE              | ACTION |
+------+---------------------+---------------------+---------------------+-------+---------------------------------------------------------------+---------------------+--------+
| 1310 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1996-09-16' | 192.168.31.201:4000 | Kill   |
| 1309 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1994-08-25' | 192.168.31.201:4000 | Kill   |
| 1308 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1997-12-13' | 192.168.31.201:4000 | Kill   |
| 1307 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1995-08-03' | 192.168.31.201:4000 | Kill   |
| 1306 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1998-07-03' | 192.168.31.201:4000 | Kill   |
| 1305 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1998-05-29' | 192.168.31.201:4000 | Kill   |
| 1304 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1996-02-20' | 192.168.31.201:4000 | Kill   |
| 1303 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1997-12-06' | 192.168.31.201:4000 | Kill   |
| 1302 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1997-03-26' | 192.168.31.201:4000 | Kill   |
| 1301 | default             | 2024-06-17 22:29:07 | 2024-06-17 22:39:07 | Exact | select  count(*) from orders where o_orderdate = '1995-08-23' | 192.168.31.201:4000 | Kill   |
+------+---------------------+---------------------+---------------------+-------+---------------------------------------------------------------+---------------------+--------+
10 rows in set (0.01 sec)

It can be seen that 1310 was removed but did not take effect.

| username: 人如其名 | Original post link

After removing an ID, it still exists in INFORMATION_SCHEMA.RUNAWAY_WATCHES, but it no longer exists in mysql.tidb_runaway_watch.

It seems that during removal, the query is made on mysql.tidb_runaway_watch, while during monitoring, the query is made on INFORMATION_SCHEMA.RUNAWAY_WATCHES.

| username: nolouch-PingCAP | Original post link

Thank you, we will first try to reproduce and locate the issue.

| username: Hacker_zuGnSsfP | Original post link

Has it been resolved? I encountered the same problem and don’t know how to solve it. Can you share your solution?

| username: nolouch-PingCAP | Original post link

@人如其名 Do you have any similar reproduction scripts for this?

| username: 人如其名 | Original post link

A temporary solution is to restart, but it is likely to recur easily.

| username: 人如其名 | Original post link

The steps I mentioned above can definitely reproduce the issue. I originally wanted to write a simpler “one-click reproduction” example, but during my testing, I executed:

ALTER RESOURCE GROUP default QUERY_LIMIT=(EXEC_ELAPSED='2ms', ACTION=KILL, WATCH=EXACT DURATION='10m');

and found it was stuck in a waiting state:


It got stuck, and after I used admin ddl cancel jobs to kill the task, it remained in a canceling state.

Restarting the tidb-server node was also ineffective.
Node information: