Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-31445

Server crashes in ha_partition::index_blocks / cost_for_index_read

    XMLWordPrintable

Details

    Description

      --source include/have_partition.inc
       
      CREATE TABLE t1 (a INT);
      CREATE TABLE t2 (b INT);
      CREATE TABLE t3 (c INT, d INT, KEY(d)) PARTITION BY KEY (c) PARTITIONS 2;
      CREATE TABLE t4 (e INT);
       
      # INSERTs and ANALYZE are optional, fails either way
      INSERT INTO t1 VALUES (1),(2);
      INSERT INTO t2 VALUES (1),(2);
      INSERT INTO t3 VALUES (1,1),(2,2);
      INSERT INTO t4 VALUES (1),(2);
      ANALYZE TABLE t1, t2, t3, t4 PERSISTENT FOR ALL;
       
      SELECT * FROM t1 LEFT JOIN (t2 JOIN t3 ON (0 IN (SELECT e FROM t4) AND t3.d = t2.b)) ON (t3.c < t2.b);
      

      11.0 5fb2c031

      #3  <signal handler called>
      #4  0x0000561f998cfd92 in ha_partition::index_blocks (this=0x61d000292cb8, index=0, ranges=1, rows=0) at /data/src/11.0/sql/ha_partition.cc:12207
      #5  0x0000561f98a12cad in handler::index_blocks (this=0x61d000292cb8, index=0) at /data/src/11.0/sql/handler.h:3668
      #6  0x0000561f98961771 in cost_for_index_read (thd=0x62b00007e218, table=0x6190000aaa98, key=0, records=1, eq_ref=false) at /data/src/11.0/sql/sql_select.cc:7979
      #7  0x0000561f989656b4 in best_access_path (join=0x629000286f78, s=0x629000294b28, remaining_tables=4, join_positions=0x6290002951f8, idx=2, disable_jbuf=false, record_count=4, pos=0x629000295f20, loose_scan_pos=0x629000296070) at /data/src/11.0/sql/sql_select.cc:8699
      #8  0x0000561f98973840 in get_costs_for_tables (join=0x629000286f78, remaining_tables=4, idx=2, record_count=4, trace_one_table=0x7f1a1b1b1ea0, pos=0x6290002951a8, store_position=0x7f1a1b1b1dc0, allowed_tables=0x7f1a1b1b1e00, stop_on_eq_ref=false) at /data/src/11.0/sql/sql_select.cc:11113
      #9  0x0000561f98974aff in best_extension_by_limited_search (join=0x629000286f78, remaining_tables=4, idx=2, record_count=4, read_time=0.03104523, search_depth=60, use_cond_selectivity=4, processed_eq_ref_tables=0x7f1a1b1b21c0) at /data/src/11.0/sql/sql_select.cc:11370
      #10 0x0000561f98976590 in best_extension_by_limited_search (join=0x629000286f78, remaining_tables=6, idx=1, record_count=2, read_time=0.010348410000000001, search_depth=61, use_cond_selectivity=4, processed_eq_ref_tables=0x7f1a1b1b25e0) at /data/src/11.0/sql/sql_select.cc:11596
      #11 0x0000561f98976590 in best_extension_by_limited_search (join=0x629000286f78, remaining_tables=7, idx=0, record_count=1, read_time=0, search_depth=62, use_cond_selectivity=4, processed_eq_ref_tables=0x7f1a1b1b28c0) at /data/src/11.0/sql/sql_select.cc:11596
      #12 0x0000561f9896f554 in greedy_search (join=0x629000286f78, remaining_tables=7, search_depth=62, use_cond_selectivity=4) at /data/src/11.0/sql/sql_select.cc:10341
      #13 0x0000561f9896cfb2 in choose_plan (join=0x629000286f78, join_tables=7, emb_sjm_nest=0x0) at /data/src/11.0/sql/sql_select.cc:9860
      #14 0x0000561f98952d13 in make_join_statistics (join=0x629000286f78, tables_list=..., keyuse_array=0x6290002872e0) at /data/src/11.0/sql/sql_select.cc:6119
      #15 0x0000561f9892e7d8 in JOIN::optimize_inner (this=0x629000286f78) at /data/src/11.0/sql/sql_select.cc:2607
      #16 0x0000561f98927845 in JOIN::optimize (this=0x629000286f78) at /data/src/11.0/sql/sql_select.cc:1935
      #17 0x0000561f989492d9 in mysql_select (thd=0x62b00007e218, tables=0x6290000e69c8, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2164525824, result=0x629000286f48, unit=0x62b000082660, select_lex=0x6290000e6370) at /data/src/11.0/sql/sql_select.cc:5168
      #18 0x0000561f98918fe8 in handle_select (thd=0x62b00007e218, lex=0x62b000082588, result=0x629000286f48, setup_tables_done_option=0) at /data/src/11.0/sql/sql_select.cc:626
      #19 0x0000561f9883e74e in execute_sqlcom_select (thd=0x62b00007e218, all_tables=0x6290000e69c8) at /data/src/11.0/sql/sql_parse.cc:6279
      #20 0x0000561f9882cb75 in mysql_execute_command (thd=0x62b00007e218, is_called_from_prepared_stmt=false) at /data/src/11.0/sql/sql_parse.cc:3949
      #21 0x0000561f988491fe in mysql_parse (thd=0x62b00007e218, rawbuf=0x6290000e6238 "SELECT * FROM t1 LEFT JOIN (t2 JOIN t3 ON (0 IN (SELECT e FROM t4) AND t3.d = t2.b)) ON (t3.c < t2.b)", length=101, parser_state=0x7f1a1b1b4a20) at /data/src/11.0/sql/sql_parse.cc:8014
      #22 0x0000561f9881f0ea in dispatch_command (command=COM_QUERY, thd=0x62b00007e218, packet=0x629000258219 "SELECT * FROM t1 LEFT JOIN (t2 JOIN t3 ON (0 IN (SELECT e FROM t4) AND t3.d = t2.b)) ON (t3.c < t2.b)", packet_length=101, blocking=true) at /data/src/11.0/sql/sql_parse.cc:1894
      #23 0x0000561f9881be03 in do_command (thd=0x62b00007e218, blocking=true) at /data/src/11.0/sql/sql_parse.cc:1407
      #24 0x0000561f98ce5336 in do_handle_one_connection (connect=0x608000002d38, put_in_cache=true) at /data/src/11.0/sql/sql_connect.cc:1416
      #25 0x0000561f98ce4cf7 in handle_one_connection (arg=0x608000002cb8) at /data/src/11.0/sql/sql_connect.cc:1318
      #26 0x0000561f998dca1c in pfs_spawn_thread (arg=0x617000005b98) at /data/src/11.0/storage/perfschema/pfs.cc:2201
      #27 0x00007f1a22ca7fd4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #28 0x00007f1a22d285bc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      Reproducible with at least MyISAM, InnoDB, Aria, HEAP.
      The failure started happening after this commit:

      commit 07b02ab40ecdbdf09dc9b975e9efe5a1bea0f133
      Author: Monty
      Date:   Fri May 26 17:26:42 2023 +0300
       
          MDEV-31356: Range cost calculations does not take into account join_buffer
      

      Attachments

        Issue Links

          Activity

            People

              monty Michael Widenius
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.