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

Server crashes in SEL_ARG::increment_use_count with index_merge+index_merge_sort_union, FORCE INDEX

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.0.4, 5.5.33a
    • Fix Version/s: 5.5.34, 10.0.7
    • Component/s: None
    • Labels:
      None

      Description

      The problem started happening on the 5.5 tree from the following revision:

      revno: 3827
      revision-id: psergey@askmonty.org-20130711111250-ako2z33co7o9tl5x
      committer: Sergey Petrunya <psergey@askmonty.org>
      timestamp: Thu 2013-07-11 15:12:50 +0400
      message:
        MDEV-4556 Server crashes in SEL_ARG::rb_insert with index_merge+index_merge_sort_union, FORCE INDEX
        - merge_same_index_scans() may put the same SEL_ARG tree in multiple result plans.
          make it call incr_refs() on the SEL_ARG trees that it does key_or() on, because
          key_or(sel_arg_tree_1, sel_arg_tree_2) call may invalidate SEL_ARG trees pointed
          by sel_arg_tree_1 and sel_arg_tree_2.

      #3  <signal handler called>
      #4  0x00000000008ee09e in SEL_ARG::increment_use_count (this=0x0, count=1) at 5.5/sql/opt_range.cc:573
      #5  0x00000000008ee157 in SEL_ARG::incr_refs (this=0x0) at 5.5/sql/opt_range.cc:584
      #6  0x00000000008d6f87 in merge_same_index_scans (param=0x7fa77dce8970, imerge=0x7fa777126850, imerge_trp=0x7fa777140b30, read_time=29.497060966859181) at 5.5/sql/opt_range.cc:4928
      #7  0x00000000008d6894 in get_best_disjunct_quick (param=0x7fa77dce8970, imerge=0x7fa777126850, read_time=29.497060966859181) at 5.5/sql/opt_range.cc:4763
      #8  0x00000000008d37d2 in SQL_SELECT::test_quick_select (this=0x7fa7771208a0, thd=0x7fa777a7e060, keys_to_use=..., prev_tables=0, limit=18446744073709551615, force_quick_range=false, ordered_output=false) at 5.5/sql/opt_range.cc:3164
      #9  0x000000000064931b in get_quick_record_count (thd=0x7fa777a7e060, select=0x7fa7771208a0, table=0x7fa777191660, keys=0x7fa77711ac30, limit=18446744073709551615) at 5.5/sql/sql_select.cc:3106
      #10 0x000000000064b1e6 in make_join_statistics (join=0x7fa777119610, tables_list=..., conds=0x7fa777258080, keyuse_array=0x7fa777119918) at 5.5/sql/sql_select.cc:3674
      #11 0x000000000064265f in JOIN::optimize (this=0x7fa777119610) at 5.5/sql/sql_select.cc:1209
      #12 0x0000000000649089 in mysql_select (thd=0x7fa777a7e060, rref_pointer_array=0x7fa777a81cb8, tables=0x7fa777257470, wild_num=1, fields=..., conds=0x7fa777258080, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7fa7771195f0, unit=0x7fa777a81378, select_lex=0x7fa777a81a50) at 5.5/sql/sql_select.cc:3055
      #13 0x000000000063fbd8 in handle_select (thd=0x7fa777a7e060, lex=0x7fa777a812c8, result=0x7fa7771195f0, setup_tables_done_option=0) at 5.5/sql/sql_select.cc:318
      #14 0x0000000000618566 in execute_sqlcom_select (thd=0x7fa777a7e060, all_tables=0x7fa777257470) at 5.5/sql/sql_parse.cc:4651
      #15 0x0000000000610fb5 in mysql_execute_command (thd=0x7fa777a7e060) at 5.5/sql/sql_parse.cc:2205
      #16 0x000000000061ae06 in mysql_parse (thd=0x7fa777a7e060, rawbuf=0x7fa777257078 "SELECT  * FROM t1 \nFORCE KEY (PRIMARY , i , c1 , c2) \nWHERE pk = 255 OR i = 22 OR (pk  IN (1 , 136) AND c2  IN ('c' , 'w') AND (c1 NOT BETWEEN 'e' AND 'i' OR  c2 > 'g'))  OR pk != 1", length=181, parser_state=0x7fa77dcec4c0) at 5.5/sql/sql_parse.cc:5769
      #17 0x000000000060e47f in dispatch_command (command=COM_QUERY, thd=0x7fa777a7e060, packet=0x7fa777bd5061 "SELECT  * FROM t1 \nFORCE KEY (PRIMARY , i , c1 , c2) \nWHERE pk = 255 OR i = 22 OR (pk  IN (1 , 136) AND c2  IN ('c' , 'w') AND (c1 NOT BETWEEN 'e' AND 'i' OR  c2 > 'g'))  OR pk != 1  ", packet_length=183) at 5.5/sql/sql_parse.cc:1071
      #18 0x000000000060d68f in do_command (thd=0x7fa777a7e060) at 5.5/sql/sql_parse.cc:794
      #19 0x0000000000715525 in do_handle_one_connection (thd_arg=0x7fa777a7e060) at 5.5/sql/sql_connect.cc:1266
      #20 0x0000000000714f0c in handle_one_connection (arg=0x7fa777a7e060) at 5.5/sql/sql_connect.cc:1181
      #21 0x000000000096576c in pfs_spawn_thread (arg=0x7fa777a839e0) at 5.5/storage/perfschema/pfs.cc:1015
      #22 0x00007fa77cebbe9a in start_thread (arg=0x7fa77dced700) at pthread_create.c:308
      #23 0x00007fa77c5eccbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

      Stack trace from

      revision-id: wlad@montyprogram.com-20130924175251-2wvjo1i166cacwam
      revno: 3921
      branch-nick: 5.5

      Test case:

      SET optimizer_switch = 'index_merge=on,index_merge_sort_union=on';
       
      CREATE TABLE t1 (
       c1 varchar(64),
       i int,
       pk integer auto_increment,
       c2 varchar(64),
       index (c1),
       index (i),
       primary key (pk),
       key (c2)) ENGINE=myisam;
       
      ALTER TABLE t1 DISABLE KEYS;
       
      INSERT INTO t1 VALUES 
      ('West Virginia', 6121, NULL, 'California'),('Georgia', 60177, NULL, 'Arkansas'),
      ('Delaware', 90, NULL, 'Oregon'),('Wyoming', 7, NULL, 'Missouri'),(
      'Delaware', 2, NULL, 'Utah'),('Wisconsin', 0, NULL, 'Iowa'),
      ('Kansas', 0, NULL, 'Florida'),('Ohio', 34358, NULL, 'Colorado'),
      ('Maine', 118, NULL, 'Texas'),('Mississippi', 0, NULL, 'Georgia'),
      ('Tennessee', 4, NULL, 'N/A'),('Georgia', 0, NULL, 'New Hampshire'),
      ('Wyoming', 2, NULL, 'N/A'),('Florida', 0, NULL, 'Arizona'),
      ('Rhode Island', -24002, NULL, 'Michigan'),('Alabama', 142, NULL, 'Indiana'),
      ('Colorado', 0, NULL, 'Louisiana'),('Michigan', 21194, NULL, 'Louisiana'),
      ('Oklahoma', 31475, NULL, 'Alabama'),('Pennsylvania', 0, NULL, 'Oklahoma'),
      ('Texas', 0, NULL, 'Texas'),('West Virginia', 5, NULL, 'Utah'),
      ('Florida', 49653, NULL, 'Kentucky'),('Tennessee', 19075, NULL, 'Oregon'),
      ('Maine', 3, NULL, 'Kansas, Kentucky, Iowa'),('Iowa', 1, NULL, 'South Dakota'),
      ('Kansas', -4037, NULL, 'Virginia'),('Delaware', 22550, NULL, 'Utah'),
      ('Illinois', 14634, NULL, 'South Carolina, Colorado'),
      ('Kansas', 6, NULL, 'South Dakota'),('Delaware', 9, NULL, ''),
      ('', 0, NULL, 'Utah, Delaware, Florida, Georgia, Nevada'),
      ('Colorado', 8, NULL, 'Montana'),('Maryland', 2689, NULL, 'Hawaii'),
      ('Florida', -12306, NULL, 'Delaware'),
      ('Indiana', 38567, NULL, 'Iowa, Minnesota, Maine'),
      ('Oklahoma', 9, NULL, 'Delaware, Kansas, Oregon, Nebraska, Maryland, Minnesota'),
      ('Tennessee', 12460, NULL, NULL),('Kentucky', 0, NULL, 'Ohio'),
      ('Nevada', 7, NULL, 'Vermont, Oregon, Oklahoma, Montana'),
      ('Nebraska', 61966, NULL, 'Nevada'),('Alaska', 131, NULL, 'Louisiana, Maine'),
      ('Wisconsin', 4, NULL, 'Nevada'),('South Carolina', 0, NULL, 'Washington'),
      ('West Virginia', 51314, NULL, 'Ohio'),('Louisiana', 0, NULL, ''),
      ('Pennsylvania', 0, NULL, 'Iowa, Idaho'),('Arkansas', 14010, NULL, 'Indiana'),
      ('Wyoming', -15514, NULL, 'Maine'),('Georgia', 0, NULL, 'N/A'),
      ('Kentucky', 1, NULL, 'Idaho'),('Wyoming', 60249, NULL, 'Indiana, Iowa'),
      ('Pennsylvania', 69, NULL, 'W'),
      ('New Mexico', 11480, NULL, 'Florida, Georgia, Hawaii'),
      ('South Carolina', 9, NULL, 'Iowa'),('Virginia', 0, NULL, 'Connecticut'),
      ('Mississippi', 19749, NULL, 'Rhode Island'),('Illinois', 5, NULL, 'Virginia'),
      ('Texas', -1749, NULL, 'Tennessee'),('Arizona', 28, NULL, 'California'),
      ('Florida', 62151, NULL, 'Kansas'),('California', 172, NULL, 'SC'),
      ('New Jersey', 0, NULL, 'North Carolina'),('Wyoming', 4, NULL, 'I'),
      ('Kansas', 10683, NULL, 'California'),('Arkansas', -14275, NULL, 'K'),
      ('Arizona', 5, NULL, 'California, Delaware, Rhode Island, Maryland'),
      ('Florida', 0, NULL, 'T'),('Alaska', 241, NULL, 'Virginia');
       
      ALTER TABLE t1 ENABLE KEYS;
       
      SELECT  * FROM t1 FORCE KEY (PRIMARY , i , c1 , c2) 
      WHERE pk = 255 OR i = 22 OR (pk  IN (1 , 136) AND c2  IN ('c' , 'w') AND (c1 NOT BETWEEN 'e' AND 'i' OR  c2 > 'g'))  OR pk != 1  ;

      EXPLAIN also crashes.

        Attachments

          Activity

            People

            • Assignee:
              psergey Sergei Petrunia
              Reporter:
              elenst Elena Stepanova
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: