[MDEV-23406] Signal 8 in maria_create after recursive cte query Created: 2020-08-05  Updated: 2020-12-17  Resolved: 2020-12-17

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - CTE
Affects Version/s: 10.2, 10.3, 10.4, 10.5
Fix Version/s: 10.2.37, 10.3.28, 10.4.18, 10.5.9

Type: Bug Priority: Major
Reporter: Alice Sherepa Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: None


 Description   

test from main.cte_recursive (line 387 -10.5) fails with --big-tables=1

set big_tables=1;
 
create table  folks(id int, name char(32), dob date, father int, mother int);
 
insert into folks values
(100, 'Me', '2000-01-01', 20, 30),
(20, 'Dad', '1970-02-02', 10, 9),
(30, 'Mom', '1975-03-03', 8, 7),
(10, 'Grandpa Bill', '1940-04-05', null, null),
(9, 'Grandma Ann', '1941-10-15', null, null),
(25, 'Uncle Jim', '1968-11-18', 8, 7),
(98, 'Sister Amy', '2001-06-20', 20, 30),
(7, 'Grandma Sally', '1943-08-23', null, 6),
(8, 'Grandpa Ben', '1940-10-21', null, null),
(6, 'Grandgrandma Martha', '1923-05-17', null, null),
(67, 'Cousin Eddie', '1992-02-28', 25, 27),
(27, 'Auntie Melinda', '1971-03-29', null, null); 
 
--echo # mutual recursion with renaming
with recursive
ancestor_couples(h_id, h_name, h_dob, h_father, h_mother,
                 w_id, w_name, w_dob, w_father, w_mother)
as
(
  select h.*, w.*
    from folks h, folks w,  coupled_ancestors a
      where a.father = h.id AND a.mother = w.id
  union
  select h.*, w.*
    from folks v, folks h, folks w
      where v.name = 'Me' and
            (v.father = h.id AND v.mother= w.id)
),
coupled_ancestors (id, name, dob, father, mother)
as
(
  select h_id, h_name, h_dob, h_father, h_mother
    from ancestor_couples
  union
  select w_id, w_name, w_dob, w_father, w_mother
    from ancestor_couples
)
select h_name, h_dob, w_name, w_dob
  from ancestor_couples;

10.2 dc716da4571465af3adadcd2

#3  <signal handler called>
#4  0x000055e8c9a257f3 in maria_create (name=0x7f45780ccb30 "/10.2/mysql-test/var/tmp/mysqld.1/#sql_6348_6", datafile_type=STATIC_RECORD, keys=0, keydefs=0x7f458a7bcb50, columns=0, columndef=0xa5a5a5a5a5a5a5a5, uniques=0, uniquedefs=0x7f458a7bcac0, ci=0x7f458a7bcb00, flags=260) at /10.2/storage/maria/ma_create.c:404
#5  0x000055e8c928f880 in create_internal_tmp_table (table=0x7f45780cb638, keyinfo=0x7f45780cd1f8, start_recinfo=0xa5a5a5a5a5a5a5a5, recinfo=0x7f457805ffc8, options=2416188160) at /10.2/sql/sql_select.cc:17855
#6  0x000055e8c91f2bb8 in mysql_derived_create (thd=0x7f4578000d50, lex=0x7f4578004888, derived=0x7f45780148d8) at /10.2/sql/sql_derived.cc:957
#7  0x000055e8c91f1036 in mysql_handle_single_derived (lex=0x7f4578004888, derived=0x7f45780148d8, phases=96) at /10.2/sql/sql_derived.cc:198
#8  0x000055e8c92814b7 in st_join_table::preread_init (this=0x7f45780dcaf8) at /10.2/sql/sql_select.cc:12106
#9  0x000055e8c9291817 in sub_select (join=0x7f4578092b58, join_tab=0x7f45780dcaf8, end_of_records=false) at /10.2/sql/sql_select.cc:18841
#10 0x000055e8c9290f41 in do_select (join=0x7f4578092b58, procedure=0x0) at /10.2/sql/sql_select.cc:18417
#11 0x000055e8c926ab20 in JOIN::exec_inner (this=0x7f4578092b58) at /10.2/sql/sql_select.cc:3638
#12 0x000055e8c9269fd8 in JOIN::exec (this=0x7f4578092b58) at /10.2/sql/sql_select.cc:3433
#13 0x000055e8c930f598 in st_select_lex_unit::exec_recursive (this=0x7f4578013220) at /10.2/sql/sql_union.cc:1291
#14 0x000055e8c91f2d23 in TABLE_LIST::fill_recursive (this=0x7f45780983e0, thd=0x7f4578000d50) at /10.2/sql/sql_derived.cc:1000
#15 0x000055e8c91f2f5d in mysql_derived_fill (thd=0x7f4578000d50, lex=0x7f4578004888, derived=0x7f45780983e0) at /10.2/sql/sql_derived.cc:1068
#16 0x000055e8c91f1036 in mysql_handle_single_derived (lex=0x7f4578004888, derived=0x7f45780983e0, phases=96) at /10.2/sql/sql_derived.cc:198
#17 0x000055e8c92814b7 in st_join_table::preread_init (this=0x7f45780df858) at /10.2/sql/sql_select.cc:12106
#18 0x000055e8c9291817 in sub_select (join=0x7f4578098b78, join_tab=0x7f45780df858, end_of_records=false) at /10.2/sql/sql_select.cc:18841
#19 0x000055e8c9290f41 in do_select (join=0x7f4578098b78, procedure=0x0) at /10.2/sql/sql_select.cc:18417
#20 0x000055e8c926ab20 in JOIN::exec_inner (this=0x7f4578098b78) at /10.2/sql/sql_select.cc:3638
#21 0x000055e8c9269fd8 in JOIN::exec (this=0x7f4578098b78) at /10.2/sql/sql_select.cc:3433
#22 0x000055e8c926b192 in mysql_select (thd=0x7f4578000d50, tables=0x7f45780983e0, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f4578098b58, unit=0x7f4578004948, select_lex=0x7f4578005088) at /10.2/sql/sql_select.cc:3833
#23 0x000055e8c925f339 in handle_select (thd=0x7f4578000d50, lex=0x7f4578004888, result=0x7f4578098b58, setup_tables_done_option=0) at /10.2/sql/sql_select.cc:361
#24 0x000055e8c922ad2c in execute_sqlcom_select (thd=0x7f4578000d50, all_tables=0x7f45780983e0) at /10.2/sql/sql_parse.cc:6218
#25 0x000055e8c92215a3 in mysql_execute_command (thd=0x7f4578000d50) at /10.2/sql/sql_parse.cc:3524
#26 0x000055e8c922ea77 in mysql_parse (thd=0x7f4578000d50, rawbuf=0x7f45780126b8 "with recursive\nancestor_couples(h_id, h_name, h_dob, h_father, h_mother,\nw_id, w_name, w_dob, w_father, w_mother)\nas\n(\nselect h.*, w.*\nfrom folks h, folks w,  coupled_ancestors a\nwhere a.father = h.id"..., length=596, parser_state=0x7f458a7be570, is_com_multi=false, is_next_command=false) at /10.2/sql/sql_parse.cc:7733
#27 0x000055e8c921cd83 in dispatch_command (command=COM_QUERY, thd=0x7f4578000d50, packet=0x7f4578008b11 "", packet_length=596, is_com_multi=false, is_next_command=false) at /10.2/sql/sql_parse.cc:1823
#28 0x000055e8c921b800 in do_command (thd=0x7f4578000d50) at /10.2/sql/sql_parse.cc:1377
#29 0x000055e8c93719eb in do_handle_one_connection (connect=0x55e8cd2c9970) at /10.2/sql/sql_connect.cc:1336
#30 0x000055e8c9371756 in handle_one_connection (arg=0x55e8cd2c9970) at /10.2/sql/sql_connect.cc:1241
#31 0x000055e8c9b88bcf in pfs_spawn_thread (arg=0x55e8cd2d2610) at /10.2/storage/perfschema/pfs.cc:1869
#32 0x00007f4591af56db in start_thread (arg=0x7f458a7bf700) at pthread_create.c:463
#33 0x00007f4590edfa3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

fails on non-debug build:

Version: '10.5.5-MariaDB-log'  
200805  9:12:04 [ERROR] mysqld got signal 8 ;
 
maria/ma_create.c:407(maria_create)[0x558d96ba0976]
sql/sql_select.cc:19598(create_internal_tmp_table(TABLE*, st_key*, st_maria_columndef*, st_maria_columndef**, unsigned long long))[0x558d96b2514f]
sql/sql_derived.cc:1086(mysql_derived_create(THD*, LEX*, TABLE_LIST*))[0x558d96b25c95]
sql/sql_derived.cc:206(mysql_handle_single_derived(LEX*, TABLE_LIST*, unsigned int))[0x558d96b99594]
sql/sql_select.cc:13579(st_join_table::preread_init())[0x558d96b99733]
sql/sql_select.cc:20603(sub_select(JOIN*, st_join_table*, bool))[0x558d96bbdf7f]
sql/sql_select.cc:20175(do_select)[0x558d96bbe1e0]
sql/sql_select.cc:4232(JOIN::exec())[0x558d96c058cc]
sql/sql_union.cc:2461(st_select_lex_unit::exec_recursive())[0x558d96b25d9e]
sql/sql_derived.cc:1138(TABLE_LIST::fill_recursive(THD*))[0x558d96b2626b]
sql/sql_derived.cc:1239(mysql_derived_fill(THD*, LEX*, TABLE_LIST*))[0x558d96b25c95]
sql/sql_derived.cc:206(mysql_handle_single_derived(LEX*, TABLE_LIST*, unsigned int))[0x558d96b99594]
sql/sql_select.cc:13579(st_join_table::preread_init())[0x558d96b99733]
sql/sql_select.cc:20603(sub_select(JOIN*, st_join_table*, bool))[0x558d96bbdf7f]
sql/sql_select.cc:20175(do_select)[0x558d96bbe1e0]
sql/sql_select.cc:4232(JOIN::exec())[0x558d96bbc582]
sql/sql_select.cc:4657(mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x558d96bbcefe]
sql/sql_select.cc:417(handle_select(THD*, LEX*, select_result*, unsigned long))[0x558d96b5f900]
sql/sql_parse.cc:6210(execute_sqlcom_select(THD*, TABLE_LIST*))[0x558d96b6861d]
sql/sql_parse.cc:5952(mysql_execute_command(THD*))[0x558d96b5abe2]
sql/sql_parse.cc:8011(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x558d96b65929]
sql/sql_parse.cc:1870(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x558d96b6687f]
sql/sql_parse.cc:1348(do_command(THD*))[0x558d96c4ca30]
sql/sql_connect.cc:1410(do_handle_one_connection(CONNECT*, bool))[0x558d96c4cdfd]
sql/sql_connect.cc:1312(handle_one_connection)[0x558d96f7724b]
nptl/pthread_create.c:487(start_thread)[0x7fbfe3ebdfa3]
x86_64/clone.S:97(clone)[0x7fbfe34c64cf]
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x7fbfcc0102e0): with recursive ancestor_couples(h_id, h_name, h_dob, h_father, h_mother, w_id, w_name, w_dob, w_father, w_mother) as ( select h.*, w.* from folks h, folks w,  coupled_ancestors a where a.father = h.id AND a.mother = w.id union select h.*, w.* from folks v, folks h, folks w where v.name = 'Me' and (v.father = h.id AND v.mother= w.id) ), coupled_ancestors (id, name, dob, father, mother) as ( select h_id, h_name, h_dob, h_father, h_mother from ancestor_couples union select w_id, w_name, w_dob, w_father, w_mother from ancestor_couples ) select h_name, h_dob, w_name, w_dob from ancestor_couples



 Comments   
Comment by Igor Babaev [ 2020-12-17 ]

A fix for this bug was pushed into 10.2

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