[MDEV-31214] Recursive CTE execution is interrupted without errors or warnings Created: 2023-05-08 Updated: 2023-07-03 Resolved: 2023-07-03 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer - CTE |
| Affects Version/s: | 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0 |
| Fix Version/s: | 10.4.31, 10.5.22, 10.6.15, 10.9.8, 10.10.6, 10.11.5, 11.0.3 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Elena Stepanova | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | 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.
1000 is a very low value, it can be reached easily in many practical use cases. For example, this simple 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. |
| Comments |
| Comment by Sergei Golubchik [ 2023-06-30 ] | ||
|
A warning would be a reasonable behavior, we already do it in similar cases:
|