[MDEV-17366] Crash using two window functions Created: 2018-10-03  Updated: 2018-10-09  Resolved: 2018-10-04

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - Window functions
Affects Version/s: 10.3.9
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Aria Stewart Assignee: Alice Sherepa
Resolution: Duplicate Votes: 0
Labels: None

Attachments: File mv_product_price_cost.sql    
Issue Links:
Duplicate
duplicates MDEV-16051 window functions crash Closed

 Description   

Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: 181003 19:47:09 [ERROR] mysqld got signal 11 ;
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: This could be because you hit a bug. It is also possible that this binary
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: or one of the libraries it was linked against is corrupt, improperly built,
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: or misconfigured. This error can also be caused by malfunctioning hardware.
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: To report this bug, see https://mariadb.com/kb/en/reporting-bugs
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: We will try our best to scrape up some info that will hopefully help
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: diagnose the problem, but since we have already crashed,
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: something is definitely wrong and this may fail.
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: Server version: 10.3.9-MariaDB
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: key_buffer_size=134217728
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: read_buffer_size=131072
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: max_used_connections=2
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: max_threads=153
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: thread_count=10
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: It is possible that mysqld could use up to
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 467396 K  bytes of memory
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: Hope that's ok; if not, decrease some variables in the equation.
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: Thread pointer: 0x7f59c40009a8
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: Attempting backtrace. You can use the following information to find out
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: where mysqld died. If you see no messages after this, something went
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: terribly wrong...
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: stack_bottom = 0x7f64e00bdd00 thread_stack 0x49000
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: *** buffer overflow detected ***: /usr/sbin/mysqld terminated
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: ======= Backtrace: =========
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /lib64/libc.so.6(__fortify_fail+0x37)[0x7f64ed0d06e7]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /lib64/libc.so.6(+0x116862)[0x7f64ed0ce862]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /lib64/libc.so.6(+0x118647)[0x7f64ed0d0647]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(my_addr_resolve+0xda)[0x563a65a4517a]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(my_print_stacktrace+0x1c2)[0x563a65a2e802]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(handle_fatal_signal+0x357)[0x563a654bef37]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /lib64/libpthread.so.0(+0xf6d0)[0x7f64eed1a6d0]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(+0x6df944)[0x563a6541e944]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(+0x6dfb75)[0x563a6541eb75]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(_ZN24Window_funcs_computation5setupEP3THDP4ListI16Item_window_funcEP13st_join_table+0x1b2)[0x563a65421ef2]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(_ZN4JOIN21make_aggr_tables_infoEv+0x170a)[0x563a6533756a]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(_ZN4JOIN15optimize_stage2Ev+0x1433)[0x563a6533e2c3]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(_ZN4JOIN14optimize_innerEv+0xfbc)[0x563a6534026c]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(_ZN4JOIN8optimizeEv+0x37)[0x563a65341a97]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(_Z22mysql_derived_optimizeP3THDP3LEXP10TABLE_LIST+0xd3)[0x563a652b62e3]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(_Z27mysql_handle_single_derivedP3LEXP10TABLE_LISTj+0xe4)[0x563a652b5bd4]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(_ZN4JOIN14optimize_innerEv+0x5a4)[0x563a6533f854]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(_ZN4JOIN8optimizeEv+0x37)[0x563a65341a97]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(_Z12mysql_selectP3THDP10TABLE_LISTjR4ListI4ItemEPS4_jP8st_orderS9_S7_S9_yP13select_resultP18st_select_lex_unitP13st_select_lex+0x94)[0x563a65343064]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(_Z13handle_selectP3THDP3LEXP13select_resultm+0x1cc)[0x563a65343bfc]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(+0x4ba19f)[0x563a651f919f]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(_Z21mysql_execute_commandP3THD+0x6c7d)[0x563a652effbd]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_statebb+0x22b)[0x563a652f27cb]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcjbb+0x1d25)[0x563a652f5315]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(_Z10do_commandP3THD+0x13e)[0x563a652f617e]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(_Z24do_handle_one_connectionP7CONNECT+0x1aa)[0x563a653c650a]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(handle_one_connection+0x3d)[0x563a653c662d]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /usr/sbin/mysqld(+0x93291d)[0x563a6567191d]
Oct 03 19:47:09 ip-10-0-192-142.ec2.internal mysqld[26921]: /lib64/libpthread.so.0(+0x7e25)[0x7f64eed12e25]



 Comments   
Comment by Alice Sherepa [ 2018-10-04 ]

Thanks for the report!
This is the same problem as MDEV-16051. On 10.2,10.3 reproduced with the similar test case, but using CTE.

CREATE TABLE t(a int)engine=innodb;
INSERT INTO t VALUES(1),(2),(3);
 
WITH cte AS
  (SELECT NTILE(124) OVER()
   FROM t
   WHERE @g NOT LIKE 1
   GROUP BY @f
   ORDER BY a)
SELECT * FROM cte;

 10.3 ae4f464fd60798627d6549bc8ecbd3a6c046cd4b
#4  0x000055982cf77a39 in Item_field::Item_field (this=0x7f56dc019130, thd=0x7f56dc000b00, f=0x0) at /10.3/sql/item.cc:3114
#5  0x000055982ce60995 in Window_funcs_sort::setup (this=0x7f56dc019098, thd=0x7f56dc000b00, sel=0x0, it=..., join_tab=0x7f56dc018a68) at /10.3/sql/sql_window.cc:3006
#6  0x000055982ce60bf0 in Window_funcs_computation::setup (this=0x7f56dc019078, thd=0x7f56dc000b00, window_funcs=0x7f56dc0152d0, tab=0x7f56dc018a68) at /10.3/sql/sql_window.cc:3046
#7  0x000055982ccb0fc9 in JOIN::make_aggr_tables_info (this=0x7f56dc017ab0) at /10.3/sql/sql_select.cc:3296
#8  0x000055982ccae5ee in JOIN::optimize_stage2 (this=0x7f56dc017ab0) at /10.3/sql/sql_select.cc:2627
#9  0x000055982ccabfcc in JOIN::optimize_inner (this=0x7f56dc017ab0) at /10.3/sql/sql_select.cc:1921
#10 0x000055982ccaa50d in JOIN::optimize (this=0x7f56dc017ab0) at /10.3/sql/sql_select.cc:1448
#11 0x000055982cc1d7be in mysql_derived_optimize (thd=0x7f56dc000b00, lex=0x7f56dc0048e8, derived=0x7f56dc016d18) at /10.3/sql/sql_derived.cc:935
#12 0x000055982cc1bd86 in mysql_handle_single_derived (lex=0x7f56dc0048e8, derived=0x7f56dc016d18, phases=4) at /10.3/sql/sql_derived.cc:197
#13 0x000055982ccab457 in JOIN::optimize_inner (this=0x7f56dc017460) at /10.3/sql/sql_select.cc:1711
#14 0x000055982ccaa50d in JOIN::optimize (this=0x7f56dc017460) at /10.3/sql/sql_select.cc:1448
#15 0x000055982ccb4064 in mysql_select (thd=0x7f56dc000b00, tables=0x7f56dc016d18, wild_num=1, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f56dc017438, unit=0x7f56dc0049b0, select_lex=0x7f56dc005120) at /10.3/sql/sql_select.cc:4220
#16 0x000055982cca605a in handle_select (thd=0x7f56dc000b00, lex=0x7f56dc0048e8, result=0x7f56dc017438, setup_tables_done_option=0) at /10.3/sql/sql_select.cc:382
#17 0x000055982cc70888 in execute_sqlcom_select (thd=0x7f56dc000b00, all_tables=0x7f56dc016d18) at /10.3/sql/sql_parse.cc:6547
#18 0x000055982cc66c37 in mysql_execute_command (thd=0x7f56dc000b00) at /10.3/sql/sql_parse.cc:3769
#19 0x000055982cc74848 in mysql_parse (thd=0x7f56dc000b00, rawbuf=0x7f56dc014d18 "with cte as (\nselect ntile(124)over() from t \nwhere @g not like 1\ngroup by @f \norder by a)\nselect * from cte", length=108, parser_state=0x7f5724a53470, is_com_multi=false, is_next_command=false) at /10.3/sql/sql_parse.cc:8091
#20 0x000055982cc61704 in dispatch_command (command=COM_QUERY, thd=0x7f56dc000b00, packet=0x7f56dc1671b1 "with cte as (\nselect ntile(124)over() from t \nwhere @g not like 1\ngroup by @f \norder by a)\nselect * from cte", packet_length=108, is_com_multi=false, is_next_command=false) at /10.3/sql/sql_parse.cc:1850
#21 0x000055982cc60121 in do_command (thd=0x7f56dc000b00) at /10.3/sql/sql_parse.cc:1395
#22 0x000055982cdc73b5 in do_handle_one_connection (connect=0x5598310b38f0) at /10.3/sql/sql_connect.cc:1402
#23 0x000055982cdc7106 in handle_one_connection (arg=0x5598310b38f0) at /10.3/sql/sql_connect.cc:1308
#24 0x000055982d69d5b6 in pfs_spawn_thread (arg=0x559831031d10) at /10.3/storage/perfschema/pfs.cc:1862
#25 0x00007f572c09b6ba in start_thread (arg=0x7f5724a54700) at pthread_create.c:333
#26 0x00007f572b53041d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Generated at Thu Feb 08 08:35:55 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.