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

Server crashes in trnman_can_read_from on select and from subqueries, Aria tables

    Details

      Description

      It's an old problem, introduced some time around 5.3.3. The test case is weird, so it's not very critical..

      Test case
      CREATE TABLE t1 (f1 INT) ENGINE=Aria;
      INSERT INTO t1 VALUES (1),(2);
      
      CREATE TABLE t2 (f2 INT, KEY(f2)) ENGINE=Aria;
      INSERT INTO t2 VALUES (8);
      
      SELECT ( SELECT MAX(f2) FROM t1 )
      FROM ( SELECT * FROM t2 ) sq;
      
      Stack trace from 5.5 commit 86f46a3da4a6d82cb510dc4c270d46cfd6a8965b
      #2  0x00000000007e7ee9 in handle_fatal_signal (sig=11) at 5.5/sql/signal_handler.cc:262
      #3  <signal handler called>
      #4  0x0000000000b8fbca in trnman_can_read_from (trn=0x0, trid=0) at 5.5/storage/maria/trnman.c:582
      #5  0x0000000000b7861c in _ma_row_visible_transactional_table (info=0x7f38f7db7060) at 5.5/storage/maria/ma_state.c:836
      #6  0x0000000000c08f9c in maria_rprev (info=0x7f38f7db7060, buf=0x7f38f7c59978 "\375\b", inx=0) at 5.5/storage/maria/ma_rprev.c:60
      #7  0x0000000000c09236 in maria_rlast (info=0x7f38f7db7060, buf=0x7f38f7c59978 "\375\b", inx=0) at 5.5/storage/maria/ma_rlast.c:25
      #8  0x0000000000b8b1f1 in ha_maria::index_last (this=0x7f38f7c79078, buf=0x7f38f7c59978 "\375\b") at 5.5/storage/maria/ha_maria.cc:2366
      #9  0x00000000006163e0 in handler::ha_index_last (this=0x7f38f7c79078, buf=0x7f38f7c59978 "\375\b") at 5.5/sql/sql_class.h:4290
      #10 0x0000000000908d52 in get_index_max_value (table=0x7f38f7cf0a60, ref=0x7f38f87b3690, range_fl=3) at 5.5/sql/opt_sum.cc:210
      #11 0x0000000000909352 in opt_sum_query (thd=0x7f38f8d50060, tables=..., all_fields=..., conds=0x0) at 5.5/sql/opt_sum.cc:400
      #12 0x00000000006658dc in JOIN::optimize (this=0x7f38f7dbcac8) at 5.5/sql/sql_select.cc:1172
      #13 0x000000000062b2d0 in st_select_lex::optimize_unflattened_subqueries (this=0x7f38f8d53a60, const_only=false) at 5.5/sql/sql_lex.cc:3506
      #14 0x000000000077ada2 in JOIN::optimize_unflattened_subqueries (this=0x7f38f7dbc078) at 5.5/sql/opt_subselect.cc:4944
      #15 0x0000000000667667 in JOIN::optimize (this=0x7f38f7dbc078) at 5.5/sql/sql_select.cc:1665
      #16 0x000000000066c45b in mysql_select (thd=0x7f38f8d50060, rref_pointer_array=0x7f38f8d53cd0, tables=0x7f38f7d6a4b0, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f38f7d6ab30, unit=0x7f38f8d53380, select_lex=0x7f38f8d53a60) at 5.5/sql/sql_select.cc:3080
      #17 0x0000000000662fbd in handle_select (thd=0x7f38f8d50060, lex=0x7f38f8d532d0, result=0x7f38f7d6ab30, setup_tables_done_option=0) at 5.5/sql/sql_select.cc:319
      #18 0x000000000063c1fc in execute_sqlcom_select (thd=0x7f38f8d50060, all_tables=0x7f38f7d6a4b0) at 5.5/sql/sql_parse.cc:4689
      #19 0x00000000006353de in mysql_execute_command (thd=0x7f38f8d50060) at 5.5/sql/sql_parse.cc:2234
      #20 0x000000000063ece2 in mysql_parse (thd=0x7f38f8d50060, rawbuf=0x7f38f7e87078 "SELECT ( SELECT MAX(f2) FROM t1 )\nFROM ( SELECT * FROM t2 ) sq", length=62, parser_state=0x7f38f87b5620) at 5.5/sql/sql_parse.cc:5909
      #21 0x0000000000632925 in dispatch_command (command=COM_QUERY, thd=0x7f38f8d50060, packet=0x7f38f8e09061 "SELECT ( SELECT MAX(f2) FROM t1 )\nFROM ( SELECT * FROM t2 ) sq", packet_length=62) at 5.5/sql/sql_parse.cc:1079
      #22 0x0000000000631ab1 in do_command (thd=0x7f38f8d50060) at 5.5/sql/sql_parse.cc:793
      #23 0x0000000000734122 in do_handle_one_connection (thd_arg=0x7f38f8d50060) at 5.5/sql/sql_connect.cc:1266
      #24 0x0000000000733be1 in handle_one_connection (arg=0x7f38f8d50060) at 5.5/sql/sql_connect.cc:1181
      #25 0x0000000000b6c629 in pfs_spawn_thread (arg=0x7f38f8d71fc0) at 5.5/storage/perfschema/pfs.cc:1015
      #26 0x00007f38ff17db50 in start_thread (arg=<optimized out>) at pthread_create.c:304
      #27 0x00007f38fd43370d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
      

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            elenst Elena Stepanova added a comment -

            on 10.x, with the same test case, the failure looks different:

            10.0/sql/handler.cc:2597: int handler::ha_index_read_map(uchar*, const uchar*, key_part_map, ha_rkey_function): Assertion `table_share->tmp_table != NO_TMP_TABLE || m_lock_type != 2' failed.
            150606 21:22:20 [ERROR] mysqld got signal 6 ;
            
            #6  0x00007f46990b5311 in *__GI___assert_fail (assertion=0xfdf818 "table_share->tmp_table != NO_TMP_TABLE || m_lock_type != 2", file=<optimized out>, line=2597, function=0xfe2180 "int handler::ha_index_read_map(uchar*, const uchar*, key_part_map, ha_rkey_function)") at assert.c:81
            #7  0x0000000000872671 in handler::ha_index_read_map (this=0x7f469187d888, buf=0x7f4693fc6088 "\375\001", key=0x7f469b2bc4a0 "\001\305+\233F\177", keypart_map=1, find_flag=HA_READ_AFTER_KEY) at 10.0/sql/handler.cc:2596
            #8  0x000000000099d381 in get_index_min_value (table=0x7f469189e470, ref=0x7f469b2bc430, item_field=0x7f46918e1e90, range_fl=6, prefix_len=0) at 10.0/sql/opt_sum.cc:157
            #9  0x000000000099db26 in opt_sum_query (thd=0x7f46947d4070, tables=..., all_fields=..., conds=0x0) at 10.0/sql/opt_sum.cc:401
            #10 0x00000000006b3b6b in JOIN::optimize_inner (this=0x7f46919f6e38) at 10.0/sql/sql_select.cc:1280
            #11 0x00000000006b2e18 in JOIN::optimize (this=0x7f46919f6e38) at 10.0/sql/sql_select.cc:1022
            #12 0x00000000006727e7 in st_select_lex::optimize_unflattened_subqueries (this=0x7f46947d80b8, const_only=false) at 10.0/sql/sql_lex.cc:3503
            #13 0x00000000007e937e in JOIN::optimize_unflattened_subqueries (this=0x7f46919f6088) at 10.0/sql/opt_subselect.cc:4971
            #14 0x00000000006b588a in JOIN::optimize_inner (this=0x7f46919f6088) at 10.0/sql/sql_select.cc:1782
            #15 0x00000000006b2e18 in JOIN::optimize (this=0x7f46919f6088) at 10.0/sql/sql_select.cc:1022
            #16 0x00000000006ba9c7 in mysql_select (thd=0x7f46947d4070, rref_pointer_array=0x7f46947d8330, tables=0x7f46918e16a0, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f4691b4bf90, unit=0x7f46947d79c8, select_lex=0x7f46947d80b8) at 10.0/sql/sql_select.cc:3294
            #17 0x00000000006b1041 in handle_select (thd=0x7f46947d4070, lex=0x7f46947d7900, result=0x7f4691b4bf90, setup_tables_done_option=0) at 10.0/sql/sql_select.cc:373
            #18 0x00000000006856f3 in execute_sqlcom_select (thd=0x7f46947d4070, all_tables=0x7f46918e16a0) at 10.0/sql/sql_parse.cc:5274
            #19 0x000000000067da24 in mysql_execute_command (thd=0x7f46947d4070) at 10.0/sql/sql_parse.cc:2562
            #20 0x000000000068824b in mysql_parse (thd=0x7f46947d4070, rawbuf=0x7f46918e0088 "SELECT ( SELECT MIN( v1.i ) FROM t2 ) FROM v1", length=45, parser_state=0x7f469b2be600) at 10.0/sql/sql_parse.cc:6529
            #21 0x000000000067ac37 in dispatch_command (command=COM_QUERY, thd=0x7f46947d4070, packet=0x7f46947ca071 "SELECT ( SELECT MIN( v1.i ) FROM t2 ) FROM v1", packet_length=45) at 10.0/sql/sql_parse.cc:1308
            #22 0x0000000000679f1d in do_command (thd=0x7f46947d4070) at 10.0/sql/sql_parse.cc:999
            #23 0x0000000000797fdf in do_handle_one_connection (thd_arg=0x7f46947d4070) at 10.0/sql/sql_connect.cc:1375
            #24 0x0000000000797d32 in handle_one_connection (arg=0x7f46947d4070) at 10.0/sql/sql_connect.cc:1289
            #25 0x0000000000cd763b in pfs_spawn_thread (arg=0x7f4693184370) at 10.0/storage/perfschema/pfs.cc:1860
            #26 0x00007f469aeafb50 in start_thread (arg=<optimized out>) at pthread_create.c:304
            #27 0x00007f469916595d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
            
            Show
            elenst Elena Stepanova added a comment - on 10.x, with the same test case, the failure looks different: 10.0/sql/handler.cc:2597: int handler::ha_index_read_map(uchar*, const uchar*, key_part_map, ha_rkey_function): Assertion `table_share->tmp_table != NO_TMP_TABLE || m_lock_type != 2' failed. 150606 21:22:20 [ERROR] mysqld got signal 6 ; #6 0x00007f46990b5311 in *__GI___assert_fail (assertion=0xfdf818 "table_share->tmp_table != NO_TMP_TABLE || m_lock_type != 2", file=<optimized out>, line=2597, function=0xfe2180 "int handler::ha_index_read_map(uchar*, const uchar*, key_part_map, ha_rkey_function)") at assert.c:81 #7 0x0000000000872671 in handler::ha_index_read_map (this=0x7f469187d888, buf=0x7f4693fc6088 "\375\001", key=0x7f469b2bc4a0 "\001\305+\233F\177", keypart_map=1, find_flag=HA_READ_AFTER_KEY) at 10.0/sql/handler.cc:2596 #8 0x000000000099d381 in get_index_min_value (table=0x7f469189e470, ref=0x7f469b2bc430, item_field=0x7f46918e1e90, range_fl=6, prefix_len=0) at 10.0/sql/opt_sum.cc:157 #9 0x000000000099db26 in opt_sum_query (thd=0x7f46947d4070, tables=..., all_fields=..., conds=0x0) at 10.0/sql/opt_sum.cc:401 #10 0x00000000006b3b6b in JOIN::optimize_inner (this=0x7f46919f6e38) at 10.0/sql/sql_select.cc:1280 #11 0x00000000006b2e18 in JOIN::optimize (this=0x7f46919f6e38) at 10.0/sql/sql_select.cc:1022 #12 0x00000000006727e7 in st_select_lex::optimize_unflattened_subqueries (this=0x7f46947d80b8, const_only=false) at 10.0/sql/sql_lex.cc:3503 #13 0x00000000007e937e in JOIN::optimize_unflattened_subqueries (this=0x7f46919f6088) at 10.0/sql/opt_subselect.cc:4971 #14 0x00000000006b588a in JOIN::optimize_inner (this=0x7f46919f6088) at 10.0/sql/sql_select.cc:1782 #15 0x00000000006b2e18 in JOIN::optimize (this=0x7f46919f6088) at 10.0/sql/sql_select.cc:1022 #16 0x00000000006ba9c7 in mysql_select (thd=0x7f46947d4070, rref_pointer_array=0x7f46947d8330, tables=0x7f46918e16a0, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f4691b4bf90, unit=0x7f46947d79c8, select_lex=0x7f46947d80b8) at 10.0/sql/sql_select.cc:3294 #17 0x00000000006b1041 in handle_select (thd=0x7f46947d4070, lex=0x7f46947d7900, result=0x7f4691b4bf90, setup_tables_done_option=0) at 10.0/sql/sql_select.cc:373 #18 0x00000000006856f3 in execute_sqlcom_select (thd=0x7f46947d4070, all_tables=0x7f46918e16a0) at 10.0/sql/sql_parse.cc:5274 #19 0x000000000067da24 in mysql_execute_command (thd=0x7f46947d4070) at 10.0/sql/sql_parse.cc:2562 #20 0x000000000068824b in mysql_parse (thd=0x7f46947d4070, rawbuf=0x7f46918e0088 "SELECT ( SELECT MIN( v1.i ) FROM t2 ) FROM v1", length=45, parser_state=0x7f469b2be600) at 10.0/sql/sql_parse.cc:6529 #21 0x000000000067ac37 in dispatch_command (command=COM_QUERY, thd=0x7f46947d4070, packet=0x7f46947ca071 "SELECT ( SELECT MIN( v1.i ) FROM t2 ) FROM v1", packet_length=45) at 10.0/sql/sql_parse.cc:1308 #22 0x0000000000679f1d in do_command (thd=0x7f46947d4070) at 10.0/sql/sql_parse.cc:999 #23 0x0000000000797fdf in do_handle_one_connection (thd_arg=0x7f46947d4070) at 10.0/sql/sql_connect.cc:1375 #24 0x0000000000797d32 in handle_one_connection (arg=0x7f46947d4070) at 10.0/sql/sql_connect.cc:1289 #25 0x0000000000cd763b in pfs_spawn_thread (arg=0x7f4693184370) at 10.0/storage/perfschema/pfs.cc:1860 #26 0x00007f469aeafb50 in start_thread (arg=<optimized out>) at pthread_create.c:304 #27 0x00007f469916595d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

              People

              • Assignee:
                monty Michael Widenius
                Reporter:
                elenst Elena Stepanova
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: