[MDEV-15853] Assertion `tab->filesort_result == 0' failed. Created: 2018-04-12  Updated: 2018-05-11  Resolved: 2018-05-11

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - Window functions
Affects Version/s: 10.2, 10.3
Fix Version/s: 10.2.15

Type: Bug Priority: Critical
Reporter: Alice Sherepa Assignee: Varun Gupta (Inactive)
Resolution: Fixed Votes: 0
Labels: None


 Description   

--source include/have_innodb.inc
 
CREATE TABLE B ( a1 int) ENGINE=InnoDB ;
CREATE TABLE C (b1 int, a1 int, a2 int) ENGINE=InnoDB ;
 
SELECT COUNT(DISTINCT C.a2),
       PERCENTILE_CONT(0.8) WITHIN GROUP (ORDER BY C.b1) OVER ()
FROM C ,B GROUP BY B.a1 ORDER BY C.a1;

Thread 1 (Thread 0x7f53b1759700 (LWP 3976)):
#0  __pthread_kill (threadid=<optimized out>, signo=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:62
#1  0x000055f4339326e9 in my_write_core (sig=6) at /home/alice/git/10.3/mysys/stacktrace.c:481
#2  0x000055f433177fcf in handle_fatal_signal (sig=6) at /home/alice/git/10.3/sql/signal_handler.cc:305
#3  <signal handler called>
#4  0x00007f53b7312428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#5  0x00007f53b731402a in __GI_abort () at abort.c:89
#6  0x00007f53b730abd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x55f433a5c56e "tab->filesort_result == 0", file=file@entry=0x55f433a5a500 "/home/alice/git/10.3/sql/sql_select.cc", line=line@entry=22323, function=function@entry=0x55f433a5eda0 <create_sort_index(THD*, JOIN*, st_join_table*, Filesort*)::__PRETTY_FUNCTION__> "int create_sort_index(THD*, JOIN*, JOIN_TAB*, Filesort*)") at assert.c:92
#7  0x00007f53b730ac82 in __GI___assert_fail (assertion=0x55f433a5c56e "tab->filesort_result == 0", file=0x55f433a5a500 "/home/alice/git/10.3/sql/sql_select.cc", line=22323, function=0x55f433a5eda0 <create_sort_index(THD*, JOIN*, st_join_table*, Filesort*)::__PRETTY_FUNCTION__> "int create_sort_index(THD*, JOIN*, JOIN_TAB*, Filesort*)") at assert.c:101
#8  0x000055f432f12d36 in create_sort_index (thd=0x7f5360000a98, join=0x7f5360188810, tab=0x7f53600dec30, fsort=0x7f536017e720) at /home/alice/git/10.3/sql/sql_select.cc:22323
#9  0x000055f43308bf56 in Window_funcs_sort::exec (this=0x7f536017e4c0, join=0x7f5360188810) at /home/alice/git/10.3/sql/sql_window.cc:2938
#10 0x000055f43308c499 in Window_funcs_computation::exec (this=0x7f536017e470, join=0x7f5360188810) at /home/alice/git/10.3/sql/sql_window.cc:3063
#11 0x000055f432f203d4 in AGGR_OP::end_send (this=0x7f536016aab0) at /home/alice/git/10.3/sql/sql_select.cc:27167
#12 0x000055f432f0abf1 in sub_select_postjoin_aggr (join=0x7f5360188810, join_tab=0x7f53600defe0, end_of_records=true) at /home/alice/git/10.3/sql/sql_select.cc:18910
#13 0x000055f432f0af21 in sub_select (join=0x7f5360188810, join_tab=0x7f53600dec30, end_of_records=true) at /home/alice/git/10.3/sql/sql_select.cc:19146
#14 0x000055f432f0ac11 in sub_select_postjoin_aggr (join=0x7f5360188810, join_tab=0x7f53600dec30, end_of_records=true) at /home/alice/git/10.3/sql/sql_select.cc:18912
#15 0x000055f432f0af21 in sub_select (join=0x7f5360188810, join_tab=0x7f53600de880, end_of_records=true) at /home/alice/git/10.3/sql/sql_select.cc:19146
#16 0x000055f432f0ad3d in sub_select_cache (join=0x7f5360188810, join_tab=0x7f53600de880, end_of_records=true) at /home/alice/git/10.3/sql/sql_select.cc:18977
#17 0x000055f432f0af21 in sub_select (join=0x7f5360188810, join_tab=0x7f53600de4d0, end_of_records=true) at /home/alice/git/10.3/sql/sql_select.cc:19146
#18 0x000055f432f0a702 in do_select (join=0x7f5360188810, procedure=0x0) at /home/alice/git/10.3/sql/sql_select.cc:18737
#19 0x000055f432ee3a6c in JOIN::exec_inner (this=0x7f5360188810) at /home/alice/git/10.3/sql/sql_select.cc:3953
#20 0x000055f432ee2ef8 in JOIN::exec (this=0x7f5360188810) at /home/alice/git/10.3/sql/sql_select.cc:3747
#21 0x000055f432ee413e in mysql_select (thd=0x7f5360000a98, tables=0x7f53600f0b30, wild_num=0, fields=..., conds=0x0, og_num=2, order=0x7f5360070c60, group=0x7f5360013a60, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f53601848f0, unit=0x7f53600048e0, select_lex=0x7f5360005078) at /home/alice/git/10.3/sql/sql_select.cc:4152
#22 0x000055f432ed6624 in handle_select (thd=0x7f5360000a98, lex=0x7f5360004818, result=0x7f53601848f0, setup_tables_done_option=0) at /home/alice/git/10.3/sql/sql_select.cc:382
#23 0x000055f432ea1ce0 in execute_sqlcom_select (thd=0x7f5360000a98, all_tables=0x7f53600f0b30) at /home/alice/git/10.3/sql/sql_parse.cc:6535
#24 0x000055f432e98072 in mysql_execute_command (thd=0x7f5360000a98) at /home/alice/git/10.3/sql/sql_parse.cc:3764
#25 0x000055f432ea5672 in mysql_parse (thd=0x7f5360000a98, rawbuf=0x7f5360184e30 "SELECT COUNT(DISTINCT C.a2),\nPERCENTILE_CONT(0.8) WITHIN GROUP (ORDER BY C.b1) OVER ()\nFROM C ,B GROUP BY B.a1 ORDER BY C.a1", length=124, parser_state=0x7f53b17585c0, is_com_multi=false, is_next_command=false) at /home/alice/git/10.3/sql/sql_parse.cc:7991
#26 0x000055f432e92a67 in dispatch_command (command=COM_QUERY, thd=0x7f5360000a98, packet=0x7f536000a5f9 "", packet_length=124, is_com_multi=false, is_next_command=false) at /home/alice/git/10.3/sql/sql_parse.cc:1841
#27 0x000055f432e9149f in do_command (thd=0x7f5360000a98) at /home/alice/git/10.3/sql/sql_parse.cc:1386
#28 0x000055f432ff3fc1 in do_handle_one_connection (connect=0x55f4373681c8) at /home/alice/git/10.3/sql/sql_connect.cc:1402
#29 0x000055f432ff3d41 in handle_one_connection (arg=0x55f4373681c8) at /home/alice/git/10.3/sql/sql_connect.cc:1308
#30 0x000055f4333b0d1e in pfs_spawn_thread (arg=0x55f4372c7568) at /home/alice/git/10.3/storage/perfschema/pfs.cc:1862
#31 0x00007f53b7f4f6ba in start_thread (arg=0x7f53b1759700) at pthread_create.c:333
#32 0x00007f53b73e441d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109



 Comments   
Comment by Varun Gupta (Inactive) [ 2018-04-23 ]

This is not specific to percentile_cont, this fails with any window function.
Another mtr test

--source include/have_innodb.inc
 
CREATE TABLE B ( a1 int) ENGINE=InnoDB ;
CREATE TABLE C (b1 int, a1 int, a2 int) ENGINE=InnoDB ;
 
SELECT COUNT(DISTINCT C.a2),
      rank() OVER (ORDER BY C.b1)
FROM C ,B GROUP BY B.a1 ORDER BY C.a1;

Comment by Varun Gupta (Inactive) [ 2018-05-08 ]

Patch
http://lists.askmonty.org/pipermail/commits/2018-May/012505.html

Comment by Vicențiu Ciorbaru [ 2018-05-08 ]

OK to push with a refactoring of the logic into a method.

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