Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
10.6, 10.7(EOL), 10.8(EOL), 10.9(EOL), 10.10(EOL), 10.11, 11.0(EOL)
-
None
Description
In the current implementation, when a recursive CTE reaches max_recursive_iterations, it just stops execution and returns a result set without an error or a warning. It wasn't a very big problem initially, as the default for max_recursive_iterations was 18446744073709551615, so it wouldn't be reachable anyway, and those who changed it presumingly would know what they are doing.
But then there was a patch in 10.6.0 which changed the default of max_recursive_iterations from the old 18446744073709551615 to 1000.
commit 831adb1e5cf5d283a5a727b396ecf75a5b207699
|
Author: Daniel Black <daniel@mariadb.org>
|
Date: Tue Mar 30 09:38:34 2021 +1100
|
 |
MDEV-17239 default max_recursive_iterations 4G -> 1000
|
1000 is a very low value, it can be reached easily in many practical use cases. For example, this simple CTE
create table t as with recursive cte as (select 1 as a union select a + 1 as a from cte where a < 10000 ) select * from cte; |
is obviously meant to create a table with 10000 values, but instead it now silently creates 1001 and succeeds afterwards.
This change could have caused any number of hidden regressions in user applications, as it's very difficult to notice.
I'm not sure what is the best way to fix it, given that it has already been in GA for a long time. Throwing an error upon reaching max_recursive_iterations is an obvious option, consistent with usual server logic, but it's a fairly big change in behavior, I don't know if it's allowed for post-GA releases.
Another option is increasing the default to a really big value.