Skip to content

Commit 831adb1

Browse files
committed
MDEV-17239 default max_recursive_iterations 4G -> 1000
A default 4G max_recursive_iterations allows users to far to easily exhaust CPU, memory and time for a incorrect query. Reduce this value down to 1000 consistent with Oracle MySQL's cte_max_recursion_depth.
1 parent 2ad61c6 commit 831adb1

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

mysql-test/main/mysqld--help.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1605,7 +1605,7 @@ max-join-size 18446744073709551615
16051605
max-length-for-sort-data 1024
16061606
max-password-errors 18446744073709551615
16071607
max-prepared-stmt-count 16382
1608-
max-recursive-iterations 18446744073709551615
1608+
max-recursive-iterations 1000
16091609
max-relay-log-size 1073741824
16101610
max-rowid-filter-size 131072
16111611
max-seeks-for-key 18446744073709551615

mysql-test/main/win_big-mdev-11697.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
set max_recursive_iterations=200000;
12
create table test_table (id int, random_data varchar(36), static_int int, static_varchar varchar(10));
23
insert into test_table(id, random_data, static_int, static_varchar)
34
select id, random_data, 42, 'Hello'
@@ -71,3 +72,4 @@ where variable_name like 'Sort_merge_passes';
7172
variable_name case when variable_value > 0 then 'WITH PASSES' else 'NO PASSES' end
7273
SORT_MERGE_PASSES WITH PASSES
7374
drop table test_table;
75+
set max_recursive_iterations=default;

mysql-test/main/win_big-mdev-11697.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
set max_recursive_iterations=200000;
12
create table test_table (id int, random_data varchar(36), static_int int, static_varchar varchar(10));
23

34
insert into test_table(id, random_data, static_int, static_varchar)
@@ -48,3 +49,4 @@ from information_schema.session_status
4849
where variable_name like 'Sort_merge_passes';
4950

5051
drop table test_table;
52+
set max_recursive_iterations=default;

sql/sys_vars.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,7 @@ static Sys_var_ulong Sys_max_recursive_iterations(
24572457
"max_recursive_iterations",
24582458
"Maximum number of iterations when executing recursive queries",
24592459
SESSION_VAR(max_recursive_iterations), CMD_LINE(OPT_ARG),
2460-
VALID_RANGE(0, UINT_MAX), DEFAULT(UINT_MAX), BLOCK_SIZE(1));
2460+
VALID_RANGE(0, UINT_MAX), DEFAULT(1000), BLOCK_SIZE(1));
24612461

24622462
static Sys_var_ulong Sys_max_sort_length(
24632463
"max_sort_length",

0 commit comments

Comments
 (0)