tidb icon indicating copy to clipboard operation
tidb copied to clipboard

max_execution_time + sleep() function doesn't work as expected

Open kolbe opened this issue 3 years ago • 1 comments

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t1 (id int unsigned not null auto_increment primary key);
insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1; insert into t1 (id) select null from t1;

set max_execution_time=2000;
select sleep(4); /* killed after 2s as expected */
select count(*) from t1 a join t1 b; /* killed after 2s as expected */

select sleep(10) from t1 a join t1 b; /* apparently never killed? */

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

The statement should be killed after max_execution_time is reached.

3. What did you see instead (Required)

The statement is not killed, and many messages are written to the tidb-server log:

[2022/08/09 17:01:28.901 -07:00] [WARN] [expensivequery.go:75] ["execution timeout, kill it"] [costTime=3m30.168889417s] [maxExecutionTime=2s] [processInfo="{id:60545707295113623, user:root, host:127.0.0.1:54593, db:test, command:Query, time:210, state:autocommit, info:select sleep(10) from t1 a join t1 b}"]

4. What is your TiDB version? (Required)

Release Version: v6.2.0-alpha
Edition: Community
Git Commit Hash: f403e198c4a9794834ae3a6930c4b01d71017a17
Git Branch: heads/refs/tags/v6.2.0-alpha
UTC Build Time: 2022-08-09 14:27:55
GoVersion: go1.18.5
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv

kolbe avatar Aug 10 '22 00:08 kolbe

the max_execution_time worked as expected

MySQL [test]> create table t1 (id int unsigned not null auto_increment primary key);
Query OK, 0 rows affected (0.02 sec)

MySQL [test]> insert into t1 values(1);
Query OK, 1 row affected (0.00 sec)

MySQL [test]> set max_execution_time=2000;
Query OK, 0 rows affected (0.00 sec)

MySQL [test]> select sleep(4);

+----------+
| sleep(4) |
+----------+
|        1 |
+----------+
1 row in set (2.07 sec)

MySQL [test]> select count(*) from t1 a join t1 b;
+----------+
| count(*) |
+----------+
|        1 |
+----------+
1 row in set (0.00 sec)

MySQL [test]> select sleep(10) from t1 a join t1 b;
+-----------+
| sleep(10) |
+-----------+
|         1 |
+-----------+
1 row in set (2.09 sec)

MySQL [test]>
MySQL [test]> select tidb_version();
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                      |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v6.2.0-alpha-658-gf403e19
Edition: Community
Git Commit Hash: f403e198c4a9794834ae3a6930c4b01d71017a17
Git Branch: master
UTC Build Time: 2022-08-10 01:06:20
GoVersion: go1.18.2
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: unistore |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

ChenPeng2013 avatar Aug 10 '22 02:08 ChenPeng2013

@ChenPeng2013 ok, it seems like you didn't execute my full test case? You didn't put enough data in the table to cause it to demonstrate the behavior I saw, apparently?

kolbe avatar Aug 12 '22 21:08 kolbe

This looks like a duplicate of https://github.com/pingcap/tidb/issues/34344

morgo avatar Aug 17 '22 15:08 morgo