[MDEV-12726] Segmentation fault in MariaDB 10.1.23 while query executing. Created: 2017-05-08  Updated: 2018-09-17  Resolved: 2017-05-08

Status: Closed
Project: MariaDB Server
Component/s: Data Manipulation - Subquery
Affects Version/s: 10.1.23
Fix Version/s: 10.1.24

Type: Bug Priority: Critical
Reporter: Sergei Butov Assignee: Unassigned
Resolution: Fixed Votes: 1
Labels: None
Environment:

Docker mariadb:10.1.23


Attachments: File test.sql    
Issue Links:
Duplicate
is duplicated by MDEV-12673 Server crashes in create_ref_for_key Closed
PartOf
includes MDEV-17221 Production Database restarted Closed

 Description   

Query:

SELECT COUNT(DISTINCT B.ID) as C 
        FROM 
        b_iblock B
        LEFT JOIN b_catalog_price CAT_P1 ON CAT_P1.PRODUCT_ID = B.ID
        WHERE
            CAT_P1.PRICE BETWEEN '109' AND '247' OR (
                B.ID IN (
                    SELECT FPV0.VALUE_NUM
                        FROM 
                        b_iblock B
                        INNER JOIN b_lang L ON B.LID=L.LID
                        INNER JOIN b_iblock_element BE ON BE.IBLOCK_ID = B.ID
                        LEFT JOIN b_iblock_property FP0 ON FP0.IBLOCK_ID = B.ID AND  FP0.ID=138
                        LEFT JOIN b_iblock_element_property FPV0 ON FPV0.IBLOCK_PROPERTY_ID = FP0.ID AND FPV0.IBLOCK_ELEMENT_ID = BE.ID
                        LEFT JOIN b_catalog_price CAT_P1 ON CAT_P1.PRODUCT_ID = BE.ID AND CAT_P1.CATALOG_GROUP_ID = 1 
                        WHERE FPV0.VALUE_NUM IS NOT NULL
                )
            );

MariaDB log:

Version: '10.1.23-MariaDB-1~jessie'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
170508  8:30:41 [ERROR] mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
 
To report this bug, see https://mariadb.com/kb/en/reporting-bugs
 
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed, 
something is definitely wrong and this may fail.
 
Server version: 10.1.23-MariaDB-1~jessie
key_buffer_size=134217728
read_buffer_size=2097152
max_used_connections=1
max_threads=102
thread_count=1
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 759834 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
 
Thread pointer: 0x7f0c01e5a008
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0x7f0c057551f8 thread_stack 0x48400
mysqld(my_print_stacktrace+0x2e)[0x55f2609da85e]
mysqld(handle_fatal_signal+0x2fd)[0x55f260513c7d]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xf890)[0x7f0c0540b890]
mysqld(+0x4497c0)[0x55f2603b57c0]
mysqld(_Z20get_best_combinationP4JOIN+0x32b)[0x55f2603ba99b]
mysqld(+0x46c37d)[0x55f2603d837d]
mysqld(_ZN4JOIN14optimize_innerEv+0x7be)[0x55f2603df4ce]
mysqld(_ZN4JOIN8optimizeEv+0x29)[0x55f2603e1d99]
mysqld(_ZN13st_select_lex31optimize_unflattened_subqueriesEb+0xd8)[0x55f26037f7c8]
mysqld(_ZN4JOIN14optimize_innerEv+0x1be2)[0x55f2603e08f2]
mysqld(_ZN4JOIN8optimizeEv+0x29)[0x55f2603e1d99]
mysqld(_Z12mysql_selectP3THDPPP4ItemP10TABLE_LISTjR4ListIS1_ES2_jP8st_orderSB_S2_SB_yP13select_resultP18st_select_lex_unitP13st_select_lex+0x8ee)[0x55f2603e273e]
mysqld(_Z13handle_selectP3THDP3LEXP13select_resultm+0x141)[0x55f2603e2921]
mysqld(+0x414de1)[0x55f260380de1]
mysqld(_Z21mysql_execute_commandP3THD+0x5c3a)[0x55f26038cc7a]
mysqld(_Z11mysql_parseP3THDPcjP12Parser_state+0x275)[0x55f26038fe65]
mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0x1c43)[0x55f260392873]
mysqld(_Z10do_commandP3THD+0x14e)[0x55f260392f9e]
mysqld(_Z24do_handle_one_connectionP3THD+0x182)[0x55f26045e8d2]
mysqld(handle_one_connection+0x40)[0x55f26045ea70]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x8064)[0x7f0c05404064]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f0c035ae62d]
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x7f0bcb024020): SELECT COUNT(DISTINCT B.ID) as C          FROM          b_iblock B         LEFT JOIN b_catalog_price CAT_P1 ON CAT_P1.PRODUCT_ID = B.ID         WHERE             CAT_P1.PRICE BETWEEN '109' AND '247' OR (                 B.ID IN (                     SELECT FPV0.VALUE_NUM                         FROM                          b_iblock B                         INNER JOIN b_lang L ON B.LID=L.LID                         INNER JOIN b_iblock_element BE ON BE.IBLOCK_ID = B.ID                         LEFT JOIN b_iblock_property FP0 ON FP0.IBLOCK_ID = B.ID AND  FP0.ID=138                         LEFT JOIN b_iblock_element_property FPV0 ON FPV0.IBLOCK_PROPERTY_ID = FP0.ID AND FPV0.IBLOCK_ELEMENT_ID = BE.ID                         LEFT JOIN b_catalog_price CAT_P1 ON CAT_P1.PRODUCT_ID = BE.ID AND CAT_P1.CATALOG_GROUP_ID = 1                          WHERE FPV0.VALUE_NUM IS NOT NULL                 )             )
Connection ID (thread ID): 2
Status: NOT_KILLED
 
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=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=off
 
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.

DB dump in attachments.
Bug is reproduced only in MariaDB 10.1.23, and is not in 10.1.22.



 Comments   
Comment by Elena Stepanova [ 2017-05-08 ]

Thanks for the report and the test case.
This problem has been filed and fixed in scope of MDEV-12673.
I've checked that the fix, when applied to 10.1, makes this variation of the crash go away.
The fix will be released with 10.1.24.
Sorry for the trouble.

Generated at Thu Feb 08 07:59:58 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.