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

Exists2In: Crash in in hp_movelink with subquery_cache=ON

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      #4  <signal handler called>
      #5  0x08526088 in hp_movelink (pos=0x9790cf0, next_link=0x0, newlink=0x9790d08)
          at /home/elenst/lp-5.5-exists2in/storage/heap/hp_hash.c:233
      #6  0x0852ab40 in hp_write_key (info=0x9752da0, keyinfo=0x97531d0, 
          record=0x97526b8  <incomplete sequence \371>, 
          recpos=0x9779f34 "\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245"...)
          at /home/elenst/lp-5.5-exists2in/storage/heap/hp_write.c:365
      #7  0x0852a237 in heap_write (info=0x9752da0, record=0x97526b8  <incomplete sequence \371>)
          at /home/elenst/lp-5.5-exists2in/storage/heap/hp_write.c:52
      #8  0x08523851 in ha_heap::write_row (this=0x9752990, buf=0x97526b8  <incomplete sequence \371>)
          at /home/elenst/lp-5.5-exists2in/storage/heap/ha_heap.cc:251
      #9  0x08297826 in handler::ha_write_tmp_row (this=0x9752990, buf=0x97526b8  <incomplete sequence \371>)
          at /home/elenst/lp-5.5-exists2in/sql/sql_class.h:4263
      #10 0x08366223 in Expression_cache_tmptable::put_value (this=0x970cea8, value=0x970ce28)
          at /home/elenst/lp-5.5-exists2in/sql/sql_expression_cache.cc:264
      #11 0x083e69e2 in Item_cache_wrapper::cache (this=0x970cdb0) at /home/elenst/lp-5.5-exists2in/sql/item.cc:7497
      #12 0x083de0cd in Item_cache_wrapper::val_bool (this=0x970cdb0)
          at /home/elenst/lp-5.5-exists2in/sql/item.cc:7660
      #13 0x083f6672 in Item_cond_or::val_int (this=0x96fe330)
          at /home/elenst/lp-5.5-exists2in/sql/item_cmpfunc.cc:4617
      #14 0x08284cb3 in evaluate_join_record (join=0x96fe570, join_tab=0x96fdc50, error=0)
          at /home/elenst/lp-5.5-exists2in/sql/sql_select.cc:15681
      #15 0x08284a9a in sub_select (join=0x96fe570, join_tab=0x96fdc50, end_of_records=false)
          at /home/elenst/lp-5.5-exists2in/sql/sql_select.cc:15626
      #16 0x0828425e in do_select (join=0x96fe570, fields=0x963e0b8, table=0x0, procedure=0x0)
          at /home/elenst/lp-5.5-exists2in/sql/sql_select.cc:15258
      #17 0x08267c3d in JOIN::exec (this=0x96fe570) at /home/elenst/lp-5.5-exists2in/sql/sql_select.cc:2739
      #18 0x08268416 in mysql_select (thd=0x963c5e8, rref_pointer_array=0x963e160, tables=0x96ecae8, wild_num=1, 
          fields=..., conds=0x96fc808, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, 
          select_options=2147748608, result=0x96fc930, unit=0x963db88, select_lex=0x963e024)
          at /home/elenst/lp-5.5-exists2in/sql/sql_select.cc:2959
      #19 0x0826016a in handle_select (thd=0x963c5e8, lex=0x963db24, result=0x96fc930, setup_tables_done_option=0)
          at /home/elenst/lp-5.5-exists2in/sql/sql_select.cc:308
      #20 0x0823c361 in execute_sqlcom_select (thd=0x963c5e8, all_tables=0x96ecae8)
          at /home/elenst/lp-5.5-exists2in/sql/sql_parse.cc:4614
      #21 0x08235308 in mysql_execute_command (thd=0x963c5e8) at /home/elenst/lp-5.5-exists2in/sql/sql_parse.cc:218
      #22 0x0823e93c in mysql_parse (thd=0x963c5e8, 
          rawbuf=0x96ec8a8 "SELECT * FROM t1 AS alias1, t1 AS alias2 \nWHERE EXISTS ( \nSELECT * FROM t1, t2 \nWHERa <= alias2.a AND c = alias1.b \n) OR alias1 .a = 'foo'", length=140, parser_state=0xad0abdb8)
          at /home/elenst/lp-5.5-exists2in/sql/sql_parse.cc:5728
      #23 0x08232dd2 in dispatch_command (command=COM_QUERY, thd=0x963c5e8, packet=0x96e2ae9 "", packet_length=140)
          at /home/elenst/lp-5.5-exists2in/sql/sql_parse.cc:1054
      #24 0x08232297 in do_command (thd=0x963c5e8) at /home/elenst/lp-5.5-exists2in/sql/sql_parse.cc:793
      #25 0x0831afae in do_handle_one_connection (thd_arg=0x963c5e8)
          at /home/elenst/lp-5.5-exists2in/sql/sql_connect.cc:1252
      #26 0x0831aafc in handle_one_connection (arg=0x963c5e8)
          at /home/elenst/lp-5.5-exists2in/sql/sql_connect.cc:1167
      #27 0x0853cfcb in pfs_spawn_thread (arg=0x966fa60)
          at /home/elenst/lp-5.5-exists2in/storage/perfschema/pfs.cc:1015
      #28 0xb771bb25 in start_thread () from /lib/libpthread.so.0

      bzr version-info

      revision-id: sanja@montyprogram.com-20120214112903-w2bmvp058v4odysy
      date: 2012-02-14 13:29:03 +0200
      build-date: 2012-02-21 04:51:42 +0400
      revno: 3268

      EXPLAIN with default optimizer_switch, exists_to_in=OFF (no crash):

      id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
      1       PRIMARY alias1  ALL     NULL    NULL    NULL    NULL    4       100.00
      1       PRIMARY alias2  ALL     NULL    NULL    NULL    NULL    4       100.00  Using where; Using join buffer (flat, BNL join)
      2       DEPENDENT SUBQUERY      t2      ALL     NULL    NULL    NULL    NULL    2       100.00  Using where
      2       DEPENDENT SUBQUERY      t1      ALL     NULL    NULL    NULL    NULL    4       100.00  Using where; Using join buffer (flat, BNL join)
      Warnings:
      Note    1276    Field or reference 'test.alias2.a' of SELECT #2 was resolved in SELECT #1
      Note    1276    Field or reference 'test.alias1.b' of SELECT #2 was resolved in SELECT #1
      Note    1003    select `test`.`alias1`.`a` AS `a`,`test`.`alias1`.`b` AS `b`,`test`.`alias2`.`a` AS `a`,`test`.`alias2`.`b` AS `b` from `test`.`t1` `alias1` join `test`.`t1` `alias2` where (<expr_cache><`test`.`alias2`.`a`,`test`.`alias1`.`b`>(exists(select 1 from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` <= `test`.`alias2`.`a`) and (`test`.`t2`.`c` = `test`.`alias1`.`b`)))) or (`test`.`alias1`.`a` = 'foo'))

      EXPLAIN with default optimizer_switch + exists_to_in=ON (crash):

      id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
      1       PRIMARY alias1  ALL     NULL    NULL    NULL    NULL    4       100.00  Using where
      1       PRIMARY alias2  ALL     NULL    NULL    NULL    NULL    4       100.00  Using join buffer (flat, BNL join)
      2       MATERIALIZED    t2      ALL     NULL    NULL    NULL    NULL    2       100.00
      2       MATERIALIZED    t1      ALL     NULL    NULL    NULL    NULL    4       100.00  Using where; Using join buffer (flat, BNL join)
      Warnings:
      Note    1276    Field or reference 'test.alias2.a' of SELECT #2 was resolved in SELECT #1
      Note    1276    Field or reference 'test.alias1.b' of SELECT #2 was resolved in SELECT #1
      Note    1003    select `test`.`alias1`.`a` AS `a`,`test`.`alias1`.`b` AS `b`,`test`.`alias2`.`a` AS `a`,`test`.`alias2`.`b` AS `b` from `test`.`t1` `alias1` join `test`.`t1` `alias2` where (<expr_cache><`test`.`alias1`.`b`,`test`.`alias2`.`a`>(<in_optimizer>(`test`.`alias1`.`b`,`test`.`alias1`.`b` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` <= `test`.`alias2`.`a`) ), <primary_index_lookup>(`test`.`alias1`.`b` in <temporary table> on distinct_key where ((`test`.`alias1`.`b` = `<subquery2>`.`c`)))))) or (`test`.`alias1`.`a` = 'foo'))

      EXPLAIN with minimal optimizer_switch in_to_exists=on,subquery_cache=on, exists_to_in=OFF, everything else off (no crash):

      id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
      1       PRIMARY alias1  ALL     NULL    NULL    NULL    NULL    4       100.00
      1       PRIMARY alias2  ALL     NULL    NULL    NULL    NULL    4       100.00  Using where; Using join buffer (flat, BNL join)
      2       DEPENDENT SUBQUERY      t2      ALL     NULL    NULL    NULL    NULL    2       100.00  Using where
      2       DEPENDENT SUBQUERY      t1      ALL     NULL    NULL    NULL    NULL    4       100.00  Using where; Using join buffer (flat, BNL join)
      Warnings:
      Note    1276    Field or reference 'test.alias2.a' of SELECT #2 was resolved in SELECT #1
      Note    1276    Field or reference 'test.alias1.b' of SELECT #2 was resolved in SELECT #1
      Note    1003    select `test`.`alias1`.`a` AS `a`,`test`.`alias1`.`b` AS `b`,`test`.`alias2`.`a` AS `a`,`test`.`alias2`.`b` AS `b` from `test`.`t1` `alias1` join `test`.`t1` `alias2` where (<expr_cache><`test`.`alias2`.`a`,`test`.`alias1`.`b`>(exists(select 1 from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` <= `test`.`alias2`.`a`) and (`test`.`t2`.`c` = `test`.`alias1`.`b`)))) or (`test`.`alias1`.`a` = 'foo'))

      EXPLAIN with minimal optimizer_switch in_to_exists=on,subquery_cache=on + exists_to_in=ON, everything else off (crash):

      id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
      1       PRIMARY alias1  ALL     NULL    NULL    NULL    NULL    4       100.00  Using where
      1       PRIMARY alias2  ALL     NULL    NULL    NULL    NULL    4       100.00  Using join buffer (flat, BNL join)
      2       DEPENDENT SUBQUERY      t2      ALL     NULL    NULL    NULL    NULL    2       100.00  Using where
      2       DEPENDENT SUBQUERY      t1      ALL     NULL    NULL    NULL    NULL    4       100.00  Using where; Using join buffer (flat, BNL join)
      Warnings:
      Note    1276    Field or reference 'test.alias2.a' of SELECT #2 was resolved in SELECT #1
      Note    1276    Field or reference 'test.alias1.b' of SELECT #2 was resolved in SELECT #1
      Note    1003    select `test`.`alias1`.`a` AS `a`,`test`.`alias1`.`b` AS `b`,`test`.`alias2`.`a` AS `a`,`test`.`alias2`.`b` AS `b` from `test`.`t1` `alias1` join `test`.`t1` `alias2` where (<expr_cache><`test`.`alias1`.`b`,`test`.`alias2`.`a`>(<in_optimizer>(`test`.`alias1`.`b`,<exists>(select `test`.`t2`.`c` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` <= `test`.`alias2`.`a`) and (<cache>(`test`.`alias1`.`b`) = `test`.`t2`.`c`))))) or (`test`.`alias1`.`a` = 'foo'))

      Minimal optimizer_switch:

      in_to_exists=on,subquery_cache=on,exists_to_in=on

      Full optimizer_switch:

      index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,exists_to_in=on

      Test case:

      SET optimizer_switch = 'in_to_exists=on,subquery_cache=on,exists_to_in=on';
       
      CREATE TABLE t1 (  
        a VARCHAR(3) NOT NULL,  
        b VARCHAR(50)
      );
      INSERT INTO t1 VALUES 
       ('USA','Chinese'),('USA','English'),
       ('FRA','French'),('ITA','Italian');
       
      CREATE TABLE t2 ( c VARCHAR(3) );
      INSERT INTO t2 VALUES ('USA'),('FRA');
       
      SELECT * FROM t1 AS alias1, t1 AS alias2 
      WHERE EXISTS ( 
        SELECT * FROM t1, t2 
        WHERE a <= alias2.a AND c = alias1.b 
      ) OR alias1 .a = 'foo';

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sanja Oleksandr Byelkin
              Reporter:
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: