[MDEV-31419] SEGV in mysqld`best_access_path Created: 2023-06-06  Updated: 2023-07-09  Resolved: 2023-07-09

Status: Closed
Project: MariaDB Server
Component/s: Server
Affects Version/s: 10.4.29
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Marcin Gryszkalis Assignee: Unassigned
Resolution: Incomplete Votes: 0
Labels: crash
Environment:

FreeBSD 12.4


Issue Links:
Duplicate
is duplicated by MDEV-31240 Crash with condition pushable into de... Closed

 Description   

After upgrading to 10.4.29 (from 10.4.28) server started crashing in some "create table ... as select" queries. The server is replica and all insert/update/delete statements are applied flawlessly.

Here's the stack trace:

* thread #1, name = 'mysqld', stop reason = signal SIGSEGV
  * frame #0: 0x0000000801eff1aa libc.so.7`__sys_kill + 10
    frame #1: 0x0000000000b60c3d mysqld`::handle_fatal_signal(sig=11) at signal_handler.cc:384:3
    frame #2: 0x0000000801c83bb0 libthr.so.3`___lldb_unnamed_symbol638 + 208
    frame #3: 0x0000000801c8316f libthr.so.3`___lldb_unnamed_symbol619 + 319
    frame #4: 0x00007ffffffff173
    frame #5: 0x0000000000d302bd mysqld`best_access_path(join=0x0000000d05bf1970, s=0x0000000d0606ea40, remaining_tables=1, join_positions=<unavailable>, idx=0, disable_jbuf=true, record_count=1, pos=0x0000000d0606eff8, loose_scan_pos=0x00007fffdb2411b0) at sql_select.cc:7453:18
    frame #6: 0x0000000000d53b2f mysqld`best_extension_by_limited_search(join=<unavailable>, remaining_tables=1, idx=0, record_count=1, read_time=0, search_depth=62, prune_level=1, use_cond_selectivity=4) at sql_select.cc:9763:7
    frame #7: 0x0000000000d3528e mysqld`choose_plan(JOIN*, unsigned long long) [inlined] greedy_search(join=0x0000000d05bf1970, remaining_tables=1, search_depth=62, prune_level=1, use_cond_selectivity=4) at sql_select.cc:8933:9
    frame #8: 0x0000000000d35131 mysqld`choose_plan(join=<unavailable>, join_tables=<unavailable>) at sql_select.cc:8495:9
    frame #9: 0x0000000000d18d52 mysqld`make_join_statistics(join=0x0000000d05bf1970, tables_list=0x0000000d05b07148, keyuse_array=0x0000000d05bf1c60) at sql_select.cc:5696:11
    frame #10: 0x0000000000d12d75 mysqld`JOIN::optimize_inner(this=0x0000000d05bf1970) at sql_select.cc:2347:7
    frame #11: 0x0000000000d0fd1e mysqld`JOIN::optimize(this=0x0000000d05bf1970) at sql_select.cc:1690:10
    frame #12: 0x0000000000c9799c mysqld`st_select_lex::optimize_unflattened_subqueries(this=0x0000000d6ba7a4f0, const_only=<unavailable>) at sql_lex.cc:4236:31
    frame #13: 0x0000000000d0feee mysqld`JOIN::optimize_stage2(this=0x0000000d05b24ad8) at sql_select.cc:3144:7
    frame #14: 0x0000000000d12ae8 mysqld`JOIN::optimize_inner(this=0x0000000d05b24ad8) at sql_select.cc:2373:9
    frame #15: 0x0000000000d0fd1e mysqld`JOIN::optimize(this=0x0000000d05b24ad8) at sql_select.cc:1690:10
    frame #16: 0x0000000000d093ff mysqld`mysql_select(thd=0x0000000d6ba550b0, tables=0x0000000d00000000, wild_num=<unavailable>, fields=0x0000000d6ba7a650, conds=<unavailable>, og_num=<unavailable>, order=0x0000000000000000, group=0x0000000d05b23ce0, having=0x0000000000000000, proc_param=0x0000000000000000, select_options=<unavailable>, result=0x0000000d05b249e0, unit=0x0000000d6ba58e48, select_lex=0x0000000d6ba7a4f0) at sql_select.cc:4797:19
    frame #17: 0x0000000000d09263 mysqld`handle_select(thd=0x0000000d6ba550b0, lex=0x0000000d6ba58d88, result=0x0000000d05b249e0, setup_tables_done_option=0) at sql_select.cc:442:10
    frame #18: 0x0000000000da584d mysqld`Sql_cmd_create_table_like::execute(this=<unavailable>, thd=0x0000000d6ba550b0) at sql_table.cc:11705:20
    frame #19: 0x0000000000cbe3e4 mysqld`mysql_execute_command(thd=0x0000000d6ba550b0) at sql_parse.cc:6206:26
    frame #20: 0x0000000000cb8af2 mysqld`mysql_parse(thd=0x0000000d6ba550b0, rawbuf=<unavailable>, length=<unavailable>, parser_state=0x00007fffdb242790, is_com_multi=false, is_next_command=<unavailable>) at sql_parse.cc:7998:18
    frame #21: 0x0000000000cb63a5 mysqld`dispatch_command(command=COM_QUERY, thd=0x0000000d6ba550b0, packet="/* ApplicationName=DBeaver 21.1.2 - SQLEditor */ create table krm.sprawy as \r\n\r\nselect\r\n\t CURRENT_DATE() as Report_Generation_Date\r\n\t"..., packet_length=1806133640, is_com_multi=false, is_next_command=false) at sql_parse.cc:1857:7
    frame #22: 0x0000000000cb9307 mysqld`do_command(thd=0x0000000d6ba550b0) at sql_parse.cc:1378:17
    frame #23: 0x0000000000e22439 mysqld`do_handle_one_connection(connect=0x0000000d04f4f990) at sql_connect.cc:1420:11
    frame #24: 0x0000000000e221f8 mysqld`::handle_one_connection(arg=0x0000000d04f4f990) at sql_connect.cc:1324:3
    frame #25: 0x0000000801c7dfd6 libthr.so.3`___lldb_unnamed_symbol538 + 326

Here's the call

frame #5: 0x0000000000d302bd mysqld`best_access_path(join=0x0000000d05bf1970, s=0x0000000d0606ea40, remaining_tables=1, join_positions=<unavailable>, idx=0, disable_jbuf=true, record_count=1, pos=0x0000000d0606eff8, loose_scan_pos=0x00007fffdb2411b0) at
 sql_select.cc:7453:18  
   7450   loose_scan_opt.init(join, s, remaining_tables);
   7451                    
   7452   if (s->table->is_splittable())
-> 7453     spl_plan= s->choose_best_splitting(idx,
   7454                                        remaining_tables,                                                              
   7455                                        &spl_pd_boundary);                                                             
   7456      

spl_pd_boundary is null:

(lldb) p spl_pd_boundary
(table_map) $3 = 0



 Comments   
Comment by Elena Stepanova [ 2023-06-06 ]

Thanks for the report.
It is most likely the same problem as MDEV-31240. The fix will be released any time now, let's keep it open until you confirm it works for you.

Generated at Thu Feb 08 10:23:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.