[MDEV-26249] Crash in in Explain_node::print_explain_for_children while writing to the slow query log Created: 2021-07-27 Updated: 2022-04-21 Resolved: 2022-01-20 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.3.22, 10.3, 10.4, 10.5, 10.6 |
| Fix Version/s: | 10.3.33, 10.4.23, 10.5.14, 10.6.6 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Valerii Kravchuk | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | excluded-select-and-explain, split_materialized | ||
| Issue Links: |
|
||||||||||||
| Description |
|
The following crash happens:
EXPLAIN for the same SELECT does not give a crash. The table t is a partitioned InnoDB table, not a view, no union involved. So, this may be different from |
| Comments |
| Comment by Alice Sherepa [ 2021-07-27 ] | |||||||||||||||||||||||||||||||||||||||||||||||
|
I've repeated on 10.3-10.6, not reproducible on 10.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2021-11-23 ] | |||||||||||||||||||||||||||||||||||||||||||||||
|
Analysis: The crash happens, because EXPLAIN data structure has the data for the select with id=1. It has a pointer to the child, select with id=2. However, there's no query plan for the select with id=2. How do we end up in this situation?
Thus, phase #2 of the optimization of select with id=2 is never done. | |||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2021-11-23 ] | |||||||||||||||||||||||||||||||||||||||||||||||
|
If I change "1=0" in the WHERE to some condition that can be satisfied (e.g. 1>0), I can see the optimization of the second select to be finished here:
That is, JOIN::optimize_stage2() is called for select with id=1, and it makes this call:
which calls JOIN::optimize() for the subquery which figures that phase #1 of the optimization is done and finishes with phase #2. | |||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2021-11-23 ] | |||||||||||||||||||||||||||||||||||||||||||||||
|
There are two ways one can fix this. When the select is optimized to "Impossible WHERE" (or some other reason why the select is degenerate), we can: A. "Complete" the optimization of derived tables. B. seems to make more sense. | |||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2021-11-23 ] | |||||||||||||||||||||||||||||||||||||||||||||||
|
bb-10.3-mdev26249. http://lists.askmonty.org/pipermail/commits/2021-November/014782.html | |||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Krivonos (Inactive) [ 2021-11-24 ] | |||||||||||||||||||||||||||||||||||||||||||||||
|
Reviewing it. Which test causes the stacktrace? | |||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2021-11-25 ] | |||||||||||||||||||||||||||||||||||||||||||||||
|
sergei.krivonos Ok, I've accidentally committed a wrong testcase, it has " 1>0" instead of "1=0". Now pushed the fixed one: bb-10.3-mdev26249 , http://lists.askmonty.org/pipermail/commits/2021-November/014786.html | |||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2021-11-25 ] | |||||||||||||||||||||||||||||||||||||||||||||||
|
Got this input:
My response is that we already do not show:
It seems to me that the direction "do not show unused parts of the query" (listed above as B) is better than A. | |||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2021-11-25 ] | |||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Krivonos (Inactive) [ 2021-12-20 ] | |||||||||||||||||||||||||||||||||||||||||||||||
|
looks ok to push | |||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2022-01-19 ] | |||||||||||||||||||||||||||||||||||||||||||||||
|
bb-10.3-mdev26249-v2, http://lists.askmonty.org/pipermail/commits/2022-January/014858.html - this is an alternative patch based on the the review input. igor, please review. | |||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2022-01-19 ] | |||||||||||||||||||||||||||||||||||||||||||||||
|
Updated patch: http://lists.askmonty.org/pipermail/commits/2022-January/014860.html | |||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2022-01-19 ] | |||||||||||||||||||||||||||||||||||||||||||||||
|
Ok to push into 10.3 |