[MDEV-26025] Server crashes while executing query with CTE in PS/SP Created: 2021-06-27 Updated: 2021-11-16 Resolved: 2021-07-21 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Procedure, Optimizer - CTE |
| Affects Version/s: | 10.5.11, 10.2, 10.3, 10.4, 10.5, 10.6 |
| Fix Version/s: | 10.2.40, 10.3.31, 10.4.21, 10.5.12, 10.6.4 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Peter VARGA | Assignee: | Igor Babaev |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | crash, feedback, regression | ||
| Environment: |
CentOS 7 |
||
| Issue Links: |
|
||||||||||||||||||||
| Description |
|
Running a quite long CTE [over 170 lines] in a procedure suddenly crashes the server. It looks to me that it started with 10.5.11 as before i worked perfectly. Below the dump. For the moment I don't want to publish the CTE but I can do it privately. Running the CTE command NOT in a stored procedure works so I have for the moment a work-around. {{Server version: 10.5.11-MariaDB Thread pointer: 0x7fdf0c0009b8 {{Connection ID (thread ID): 10 Optimizer switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off}} |
| Comments |
| Comment by Elena Stepanova [ 2021-06-28 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Could you please upload the query, structures of all involved tables, definition of the procedure, and your cnf file(s) to ftp://ftp.askmonty.org/private? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Peter VARGA [ 2021-06-28 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hm, I may now sound stupid but I am asked for a user. What should I enter? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Peter VARGA [ 2021-06-28 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This was really a very stupid question I asked. I uploaded now the archive @Issue: {{CALL CheckVehicleConflicts('562639cf-7ef5-4404-ad6a-f8a98b0c1fb6'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2021-06-29 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the provided data. Reproducible as described. Resolved ASAN stack trace from the original test case:
Smaller test case derived from the original one:
(Stored procedure was replaced with a prepared statement for the purpose of bisecting, as the stored procedure wouldn't work on 10.2 till recently due to Crashes with somewhat varying stack traces are reproducible on 10.2-10.6, debug and non-debug builds. The failure started happening after this commit in 10.2:
Additionally, here is a slightly different test case (select-star instead of COUNT), it causes a debug assertion failure instead of a crash:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2021-07-20 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The following simple test demonstrate the problem:
Execution of this test case causes a crash of the server. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2021-07-20 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
An analysis shows that the SELECT created for the second usage of cte1 via the usage of cte2 is not included in all_select_list for the query. It happens for the same reason as the similar problem of the bug
The difference between this patch and the patch for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2021-07-20 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The cause of both bugs is the same and they should be fixed by the same patch. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2021-07-20 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
OK to push | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2021-07-21 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
A fix for this bug was pushed into 10.2. A special care should be taken when merging this patch into 10.4: the fix for |