[MDEV-17014] Crash server using ROW_NUMBER() OVER (PARTITION ..) with an EXISTS() Created: 2018-08-18  Updated: 2018-08-21  Resolved: 2018-08-20

Status: Closed
Project: MariaDB Server
Component/s: Data Manipulation - Subquery, Storage Engine - InnoDB
Affects Version/s: 10.2.16, 10.2.17
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Nicholas Denning Assignee: Alice Sherepa
Resolution: Duplicate Votes: 0
Labels: None
Environment:

centos 7 fully yum updated.


Attachments: Text File error_mariadb.log     Text File query_mariadb.log     File server.cnf     Text File slowqry_mariadb.log     Text File sqlaudit.log    
Issue Links:
Duplicate
duplicates MDEV-15178 Filesort::make_sortorder: Assertion `... Closed

 Description   

The following script crashes the server. We encountered this on 10.2.16 and I have also tested this on 10.2.17 and its the the same. We think the problem is the EXISTS() element.

DROP TABLE IF EXISTS TEST_TABLE_1;
CREATE TABLE TEST_TABLE_1 (
UID BIGINT
);

DROP TABLE IF EXISTS TEST_TABLE_2;
CREATE TABLE TEST_TABLE_2 (
UID BIGINT
);

DROP TABLE IF EXISTS TEST_TABLE_3;
CREATE TABLE TEST_TABLE_3 (
UID BIGINT
);

SELECT
ROW_NUMBER() OVER (PARTITION BY GROUP_CONCAT(TT1.UID))
FROM TEST_TABLE_1 TT1
WHERE EXISTS (
SELECT *
FROM TEST_TABLE_2 TT2
JOIN TEST_TABLE_3 TT3 ON TT2.UID = TT3.UID
WHERE TT3.UID = TT1.UID
)
GROUP BY TT1.UID
;



 Comments   
Comment by Alice Sherepa [ 2018-08-20 ]

Thanks for the report!
It looks like it is the same bug as MDEV-15178, on debug version it fails
with assertion `pos->field != __null || pos->item != __null' in Filesort::make_sortorder:

Thread 1 (Thread 0x7f3f39648700 (LWP 17201)):
#0  __pthread_kill (threadid=<optimized out>, signo=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:62
#1  0x00005561be5ea748 in my_write_core (sig=6) at /10.3/mysys/stacktrace.c:481
#2  0x00005561bde2e4e9 in handle_fatal_signal (sig=6) at /10.3/sql/signal_handler.cc:305
#3  <signal handler called>
#4  0x00007f3f40052428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#5  0x00007f3f4005402a in __GI_abort () at abort.c:89
#6  0x00007f3f4004abd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x5561be8128e8 "pos->field != __null || pos->item != __null", file=file@entry=0x5561be812708 "/10.3/sql/filesort.cc", line=line@entry=492, function=function@entry=0x5561be813000 <Filesort::make_sortorder(THD*, JOIN*, unsigned long long)::__PRETTY_FUNCTION__> "uint Filesort::make_sortorder(THD*, JOIN*, table_map)") at assert.c:92
#7  0x00007f3f4004ac82 in __GI___assert_fail (assertion=0x5561be8128e8 "pos->field != __null || pos->item != __null", file=0x5561be812708 "/10.3/sql/filesort.cc", line=492, function=0x5561be813000 <Filesort::make_sortorder(THD*, JOIN*, unsigned long long)::__PRETTY_FUNCTION__> "uint Filesort::make_sortorder(THD*, JOIN*, table_map)") at assert.c:101
#8  0x00005561bde28e83 in Filesort::make_sortorder (this=0x7f3ee81130b8, thd=0x7f3ee8000b00, join=0x7f3ee8018c50, first_table_bit=1) at /10.3/sql/filesort.cc:492
#9  0x00005561bde279ee in filesort (thd=0x7f3ee8000b00, table=0x7f3ee8114bc8, filesort=0x7f3ee81130b8, tracker=0x7f3ee81133a8, join=0x7f3ee8018c50, first_table_bit=1) at /10.3/sql/filesort.cc:158
#10 0x00005561bdbbd3ed in create_sort_index (thd=0x7f3ee8000b00, join=0x7f3ee8018c50, tab=0x7f3ee8111678, fsort=0x7f3ee81130b8) at /10.3/sql/sql_select.cc:22422
#11 0x00005561bdd39d17 in Window_funcs_sort::exec (this=0x7f3ee8113020, join=0x7f3ee8018c50) at /10.3/sql/sql_window.cc:2938
#12 0x00005561bdd3a25f in Window_funcs_computation::exec (this=0x7f3ee8113000, join=0x7f3ee8018c50) at /10.3/sql/sql_window.cc:3063
#13 0x00005561bdbcaac2 in AGGR_OP::end_send (this=0x7f3ee8112550) at /10.3/sql/sql_select.cc:27254
#14 0x00005561bdbb5128 in sub_select_postjoin_aggr (join=0x7f3ee8018c50, join_tab=0x7f3ee8111678, end_of_records=true) at /10.3/sql/sql_select.cc:18999
#15 0x00005561bdbb5453 in sub_select (join=0x7f3ee8018c50, join_tab=0x7f3ee81112c8, end_of_records=true) at /10.3/sql/sql_select.cc:19234
#16 0x00005561bdbb5274 in sub_select_cache (join=0x7f3ee8018c50, join_tab=0x7f3ee81112c8, end_of_records=true) at /10.3/sql/sql_select.cc:19066
#17 0x00005561bdbb5453 in sub_select (join=0x7f3ee8018c50, join_tab=0x7f3ee8110f18, end_of_records=true) at /10.3/sql/sql_select.cc:19234
#18 0x00005561bdbb5274 in sub_select_cache (join=0x7f3ee8018c50, join_tab=0x7f3ee8110f18, end_of_records=true) at /10.3/sql/sql_select.cc:19066
#19 0x00005561bdbb5453 in sub_select (join=0x7f3ee8018c50, join_tab=0x7f3ee8110b68, end_of_records=true) at /10.3/sql/sql_select.cc:19234
#20 0x00005561bdbb4c1d in do_select (join=0x7f3ee8018c50, procedure=0x0) at /10.3/sql/sql_select.cc:18825
#21 0x00005561bdb8dead in JOIN::exec_inner (this=0x7f3ee8018c50) at /10.3/sql/sql_select.cc:4028
#22 0x00005561bdb8d320 in JOIN::exec (this=0x7f3ee8018c50) at /10.3/sql/sql_select.cc:3822
#23 0x00005561bdb8e587 in mysql_select (thd=0x7f3ee8000b00, tables=0x7f3ee8015908, wild_num=0, fields=..., conds=0x7f3ee8018800, og_num=1, order=0x0, group=0x7f3ee8018af8, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f3ee8018c30, unit=0x7f3ee80049a8, select_lex=0x7f3ee8005118) at /10.3/sql/sql_select.cc:4227
#24 0x00005561bdb8050a in handle_select (thd=0x7f3ee8000b00, lex=0x7f3ee80048e0, result=0x7f3ee8018c30, setup_tables_done_option=0) at /10.3/sql/sql_select.cc:382
#25 0x00005561bdb4ade6 in execute_sqlcom_select (thd=0x7f3ee8000b00, all_tables=0x7f3ee8015908) at /10.3/sql/sql_parse.cc:6546
#26 0x00005561bdb4123f in mysql_execute_command (thd=0x7f3ee8000b00) at /10.3/sql/sql_parse.cc:3768
#27 0x00005561bdb4ed6b in mysql_parse (thd=0x7f3ee8000b00, rawbuf=0x7f3ee8014d08 "SELECT ROW_NUMBER() OVER (PARTITION BY GROUP_CONCAT(TT1.UID))\nFROM TEST_TABLE_1 TT1\nWHERE EXISTS\n(SELECT *\nFROM TEST_TABLE_2 TT2\nJOIN TEST_TABLE_3 TT3 ON TT2.UID = TT3.UID\nWHERE TT3.UID = TT1.UID)\nGRO"..., length=213, parser_state=0x7f3f39647470, is_com_multi=false, is_next_command=false) at /10.3/sql/sql_parse.cc:8088
#28 0x00005561bdb3bd14 in dispatch_command (command=COM_QUERY, thd=0x7f3ee8000b00, packet=0x7f3ee800b211 "", packet_length=214, is_com_multi=false, is_next_command=false) at /10.3/sql/sql_parse.cc:1850
#29 0x00005561bdb3a731 in do_command (thd=0x7f3ee8000b00) at /10.3/sql/sql_parse.cc:1395
#30 0x00005561bdca0c25 in do_handle_one_connection (connect=0x5561c1b34510) at /10.3/sql/sql_connect.cc:1402
#31 0x00005561bdca0976 in handle_one_connection (arg=0x5561c1b34510) at /10.3/sql/sql_connect.cc:1308
#32 0x00005561be57ac28 in pfs_spawn_thread (arg=0x5561c1b47eb0) at /10.3/storage/perfschema/pfs.cc:1862
#33 0x00007f3f40c8f6ba in start_thread (arg=0x7f3f39648700) at pthread_create.c:333
#34 0x00007f3f4012441d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

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