Setting max_execution_time seemingly only works on the system.numbers table, which is the only table that the setting is tested on.
A simple test can be done on one of our access log tables.
$ clickhouse-client -t --max_execution_time 1 -q 'SELECT uniq(_date) FROM clicktail.access_log WHERE _date = today()';
1
4.445
$ clickhouse-client -t --max_execution_time 1 -q 'SELECT count() from system.numbers';
Received exception from server (version 19.17.6):
Code: 159. DB::Exception: Received from localhost:9000. DB::Exception: Timeout exceeded: elapsed 1.000091896 seconds, maximum: 1.
0.998
This has been tested on both 19.17.6.36 and 19.17.4.11.
Let me know if you need any additional information.
It is not ignored, but it kills queries 'gracefully'.
I.e. it just set a flag "it's enough" and that flag is checked at some moments of query execution by working threads.
@filimonov No, it's a real issue
create table X (A Int64) Engine=MergeTree order by tuple();
insert into X select cityHash64(number) from numbers(10000000000);
19.4.5.35.
time cl --max_execution_time 1 -q 'select count() from X where A=1'
Received exception from server (version 19.4.5):
Code: 159. DB::Exception: Received from localhost:9000, ::1. DB::Exception: Timeout exceeded: elapsed 1.003994507 seconds, maximum: 1.
real 0m1.041s
user 0m0.009s
sys 0m0.009s
19.16.9.37
time cl --max_execution_time=1 -q 'select count() from X where A=1'
Received exception from server (version 19.16.9):
Code: 159. DB::Exception: Received from localhost:9000. DB::Exception: Timeout exceeded: elapsed 1.00399474 seconds, maximum: 1.
real 0m1.040s
user 0m0.000s
sys 0m0.014s
19.17.5.18
time cl --max_execution_time 1 -q 'select count() from X where A=1'
real 0m31.997s
user 0m0.003s
sys 0m0.025s
No Timeout error!!!
Same problem
same problem.Here is my test result.
First picture is the old version(1.1.54380)'s test result.

Second picture is the new version(19.17.6.36)'s test result

@weiyongyuan you put pictures in the wrong order
@weiyongyuan you put pictures in the wrong order
oh sorry,I already put them correctly
It works now in master and was accidentally fixed after #7796. So I have just backported #7796 back to 19.17 and 20.1. And added a test for MergeTree.
xxx :) set max_execution_time = 1 ;
SET max_execution_time = 1
Ok.
0 rows in set. Elapsed: 0.001 sec.
xxx :)
xxx :) select sleep(3);
SELECT sleep(3)
ββsleep(3)ββ
β 0 β
ββββββββββββ
1 rows in set. Elapsed: 3.001 sec.
xxx :) select version();
SELECT version()
ββversion()ββ
β 20.4.3.16 β
βββββββββββββ
@jackpgao it works as expected. Timeout check happens in between blocks. You need more blocks
set max_execution_time = 1 ;
select sleep(1) from numbers(10) settings max_block_size=1;
Code: 159. DB::Exception: Received from localhost:9000. DB::Exception: Timeout exceeded: elapsed 1.999990824 seconds, maximum: 1
@jackpgao it works as expected. Timeout check happens in between blocks. You need more blocks
set max_execution_time = 1 ; select sleep(1) from numbers(10) settings max_block_size=1; Code: 159. DB::Exception: Received from localhost:9000. DB::Exception: Timeout exceeded: elapsed 1.999990824 seconds, maximum: 1
SELECT *
FROM system.settings
WHERE name LIKE '%max_block_size%'
ββnameββββββββββββ¬βvalueββ¬βchangedββ¬βdescriptionβββββββββββββββββββββ¬βminβββ¬βmaxβββ¬βreadonlyββ
β max_block_size β 65536 β 0 β Maximum block size for reading β α΄Ία΅α΄Έα΄Έ β α΄Ία΅α΄Έα΄Έ β 0 β
ββββββββββββββββββ΄ββββββββ΄ββββββββββ΄βββββββββββββββββββββββββββββββββ΄βββββββ΄βββββββ΄βββββββββββ
max_execution_time setting in users.xmlactually some of my query will execute exceed the max_execution_time
All queries always execute longer than max_execution_time.
set max_execution_time = 1 ;
select sleepEachRow(3) from numbers(1000) settings max_block_size=20;
DB::Exception: Timeout exceeded: elapsed 59.999714133 seconds, maximum: 1
The first block executes for 60 seconds (20rows * 3 sec). Then the max_execution_time check happens.
actually some of my query will execute exceed the max_execution_time
All queries always execute longer than max_execution_time.
set max_execution_time = 1 ;
select sleepEachRow(3) from numbers(1000) settings max_block_size=20;
DB::Exception: Timeout exceeded: elapsed 59.999714133 seconds, maximum: 1The first block executes for 60 seconds (20rows * 3 sec). Then the
max_execution_timecheck happens.
Sorry, my fault. It indeed works.
My testing way is not correct.