[MDEV-10972] Insert from select / view / union -- repeatable crash in 10.1, 10.2 Linux/Mac/Windows Created: 2016-10-06 Updated: 2018-09-01 Resolved: 2017-09-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.1.18, 10.2.1, 10.1, 10.2 |
| Fix Version/s: | 10.1.27, 10.2.9, 10.3.2 |
| Type: | Bug | Priority: | Major |
| Reporter: | Michael Newcomb | Assignee: | Oleksandr Byelkin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Centos 7 AWS but also Sierra and Windows 10 |
||
| Issue Links: |
|
||||||||||||||||||||
| Sprint: | 10.1.19, 10.2.4-1, 10.2.4-2 | ||||||||||||||||||||
| Description |
|
I've hit what appears to be an optimizer bug that crashes the server daemon. The test case works fine on 10.0.x but fails on 10.1.18 and 10.2.1. |
| Comments |
| Comment by Michael Newcomb [ 2016-10-06 ] | |||||||||||||||||||||||||||||||||
|
Uploaded test case data to ftp.askmonty.org/private/ Steps I use to reproduce the error:
This should create a test database. To cause the crash run the provoke shell script or:
This causes a crash 100% of the time for me. The Zip file includes server.cnf and the log files from my test instance. The same code runs fine on 10.0.27. If there's anything I can do to help please let me know... Thanks for your help! | |||||||||||||||||||||||||||||||||
| Comment by Michael Newcomb [ 2016-10-06 ] | |||||||||||||||||||||||||||||||||
|
Offending statement looks like this:
| |||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-10-07 ] | |||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-10-08 ] | |||||||||||||||||||||||||||||||||
|
mnewcomb2016, thanks for the report and test case. sanja, below is a smaller test for debugging; but after fixing, please make sure that your fix also works for the initial test case!
| |||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-01-11 ] | |||||||||||||||||||||||||||||||||
|
The problem is that we have 2 SELECT # 2 | |||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-01-11 ] | |||||||||||||||||||||||||||||||||
|
There is only 1 select #2, but explain information was not cleaned after error, which causes problem: | |||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-01-13 ] | |||||||||||||||||||||||||||||||||
|
OK, despite the same SQL inside it is 2 different SELECT_LEX & JOIN with number #2 and number #3 and both part of the view UNION. | |||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-01-15 ] | |||||||||||||||||||||||||||||||||
|
mysql_make_view works only in CALL without error. | |||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-01-15 ] | |||||||||||||||||||||||||||||||||
|
first time mysql_new_select called during compiling call with error, second during mysql_make_view in normal CALL. | |||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-01-15 ] | |||||||||||||||||||||||||||||||||
|
If there is no error all calls made in the same first CALL, and everything is OK. | |||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-01-15 ] | |||||||||||||||||||||||||||||||||
|
Normal execution has only one select #2 and one #3 used everywhere (as it should). | |||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-01-15 ] | |||||||||||||||||||||||||||||||||
|
incorrect switching Query_arenas ? | |||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-01-16 ] | |||||||||||||||||||||||||||||||||
|
Correct execution has the same SELECT_LEX (why view selects 2 times?), but counting them from beginning because process divided between 2 calls cause the problem we observe. | |||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-01-16 ] | |||||||||||||||||||||||||||||||||
|
Workaround can be store thd->select_number and then restore it before execution, but what is statement like this will not be the first in the procedure. | |||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-01-17 ] | |||||||||||||||||||||||||||||||||
|
There is other way (without error) to repeat the problem. It need just other statement to reset thd->select_number between parsing and execution.
| |||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-01-17 ] | |||||||||||||||||||||||||||||||||
|
As a solution I see storing the counter (thd->select_number) in sp_head and restore it before each instruction. | |||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-01-17 ] | |||||||||||||||||||||||||||||||||
|
Above was wrong (rests of experimenting with instructions). Stored procedure do not reset the counter between instructions, so it number all selects in the procedure. | |||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-01-17 ] | |||||||||||||||||||||||||||||||||
|
Problem present in 5.5/10.0 but do not lead to crash, because it has different EXPLAIN system. | |||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-01-17 ] | |||||||||||||||||||||||||||||||||
|
revision-id: f360516046af16336e874b1ab9fb22efb1881723 (mariadb-10.1.20-33-gf360516046a)
save thd->select_number between parsing and executions (in case it was not complete executed due to errors (for example epsent table)) — | |||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-01-17 ] | |||||||||||||||||||||||||||||||||
|
The very first SELECT_LEX which belong to LEX should not be a problem. | |||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-09-04 ] | |||||||||||||||||||||||||||||||||
|
revision-id: c62864b57568e81d77a1ffa2d7ad96d5daccfe97 (mariadb-10.1.26-26-gc62864b5756) Post review change (prevents contant increasing, which harmless but not right) — | |||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2017-09-04 ] | |||||||||||||||||||||||||||||||||
|
Review input provided in chat window. Ok to push after addressed. |