Skip to content

Evaluating a scalar non-correlated subquery will invalidate the RunawayChecker #61899

@JmPotato

Description

@JmPotato

Bug Report

1. Minimal reproduce step (Required)

create table t1(a int, b int);
insert into t1 value(rand()*1000, rand()*1000); x 44600

mysql> select count(*) from t1;
+----------+
| count(*) |
+----------+
|    44600 |
+----------+
1 row in set (0.01 sec)

mysql> CREATE RESOURCE GROUP IF NOT EXISTS rg1 RU_PER_SEC = 100 QUERY_LIMIT=(RU=10, ACTION=KILL);
Query OK, 0 rows affected (0.06 sec)

mysql> SET RESOURCE GROUP rg1;
Query OK, 0 rows affected (0.00 sec)

mysql> explain analyze select * from t1 where b > (select min(a)+3 from t1 where a < 452);
+--------------------------+----------+---------+-----------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------+----------+------+
| id                       | estRows  | actRows | task      | access object | execution info                                                                                                                                                                                                                                                                                                                                                                                                                             | operator info                                    | memory   | disk |
+--------------------------+----------+---------+-----------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------+----------+------+
| TableReader_36           | 18466.67 | 44437   | root      |               | time:17.6ms, loops:46, RU:77.201538, cop_task: {num: 9, max: 5.94ms, min: 359.8µs, avg: 1.95ms, p95: 5.94ms, max_proc_keys: 17376, p95_proc_keys: 17376, tot_proc: 15.3ms, tot_wait: 195.8µs, copr_cache_hit_ratio: 0.00, build_task_duration: 2.42µs, max_distsql_concurrency: 1}, rpc_info:{Cop:{num_rpc:9, total_time:17.5ms}}                                                                                                          | data:Selection_35                                | 414.5 KB | N/A  |
| └─Selection_35           | 18466.67 | 44437   | cop[tikv] |               | tikv_task:{proc max:5ms, min:0s, avg: 1.44ms, p80:3ms, p95:5ms, iters:79, tasks:9}, scan_detail: {total_process_keys: 44600, total_process_keys_size: 1906316, total_keys: 44609, get_snapshot_time: 79.5µs, rocksdb: {key_skipped_count: 44600, block: {cache_hit_count: 84}}}, time_detail: {total_process_time: 15.3ms, total_suspend_time: 11.5µs, total_wait_time: 195.8µs, total_kv_read_wall_time: 13ms, tikv_wall_time: 15.9ms}    | gt(test.t1.b, 3)                                 | N/A      | N/A  |
|   └─TableFullScan_34     | 55400.00 | 44600   | cop[tikv] | table:t1      | tikv_task:{proc max:5ms, min:0s, avg: 1.44ms, p80:3ms, p95:5ms, iters:79, tasks:9}                                                                                                                                                                                                                                                                                                                                                         | keep order:false, stats:partial[b:unInitialized] | N/A      | N/A  |
+--------------------------+----------+---------+-----------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------+----------+------+
3 rows in set (0.05 sec)

mysql> explain analyze select * from t1 where b > 36;
ERROR 8253 (HY000): Query execution was interrupted, identified as runaway query [RequestUnit = RRU:12.955640, WRU:0.000000, WaitDuration:0s(10)]
mysql> explain analyze select min(a)+10 from t1 where a < 639;
ERROR 8253 (HY000): Query execution was interrupted, identified as runaway query [RequestUnit = RRU:37.636963, WRU:0.000000, WaitDuration:0s(10)]

2. What did you expect to see? (Required)

The SQL with subquery should be killed since its RUs exceed the limit.

3. What did you see instead (Required)

The SQL successfully returned with RUs exceeded the limit.

4. What is your TiDB version? (Required)

https://github.com/pingcap/tidb/releases/tag/v8.5.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-8.1This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.affects-9.0This bug affects the 9.0.x versions.component/pdseverity/majortype/bugThe issue is confirmed as a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions