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

Server crashes in best_access_path after a sequence of SELECTs invollving a temptable view

    XMLWordPrintable

Details

    Description

      IMPORTANT: The crash only happens on a non-debug build (CMAKE_BUILD_TYPE-RelWithDebInfo), both on a handmade build and on release binaries. Reproduced on two mahines out of two that I tried (Debian and Windows).
      On a debug build, there is no crash and no valgrind errors.

      The problem appeared in 10.0 tree after this merge:

      revno: 4404 [merge]
      revision-id: sergii@pisem.net-20140916120805-z8w9eowbu0npzzt7
      parent: jplindst@mariadb.org-20140916043700-0se7ircabn8z8ntx
      parent: sergii@pisem.net-20140916120450-c892fq11sn6sqgdc
      committer: Sergei Golubchik <sergii@pisem.net>
      branch nick: 10.0
      timestamp: Tue 2014-09-16 14:08:05 +0200
      message:
        merge

      which is a 5.5 merge, but I am not getting the crash on 5.5 tree (which doesn't mean the problem doesn't exist there).

      Stack trace from revno 4426

      #2  <signal handler called>
      #3  best_access_path (join=join@entry=0x7f1235dcc020, s=s@entry=0x7f1235e6ca40, remaining_tables=remaining_tables@entry=2, idx=idx@entry=2, disable_jbuf=true, record_count=1, record_count@entry=<error reading variable: Could not find type for DW_OP_GNU_const_type>, pos=0x7f1235e6d4e0, loose_scan_pos=loose_scan_pos@entry=0x7f123fad38a0) at 10.0/sql/sql_select.cc:6003
      #4  0x00000000005fe4e3 in best_extension_by_limited_search (join=join@entry=0x7f1235dcc020, remaining_tables=remaining_tables@entry=2, idx=idx@entry=2, record_count=1, read_time=0, read_time@entry=<error reading variable: Could not find type for DW_OP_GNU_const_type>, search_depth=search_depth@entry=62, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=1) at 10.0/sql/sql_select.cc:7661
      #5  0x00000000005fe8ce in greedy_search (join=join@entry=0x7f1235dcc020, remaining_tables=remaining_tables@entry=2, search_depth=62, prune_level=prune_level@entry=1, use_cond_selectivity=1) at 10.0/sql/sql_select.cc:6902
      #6  0x00000000005fed27 in choose_plan (join=join@entry=0x7f1235dcc020, join_tables=2) at 10.0/sql/sql_select.cc:6479
      #7  0x000000000053fac4 in make_join_statistics (join=join@entry=0x7f1235dcc020, tables_list=..., conds=0x7f1235e6df00, keyuse_array=keyuse_array@entry=0x7f1235dcc328) at 10.0/sql/sql_select.cc:4023
      #8  0x0000000000618044 in JOIN::optimize_inner (this=this@entry=0x7f1235dcc020) at 10.0/sql/sql_select.cc:1339
      #9  0x000000000061a19d in JOIN::optimize (this=this@entry=0x7f1235dcc020) at 10.0/sql/sql_select.cc:1024
      #10 0x000000000061a355 in mysql_select (thd=thd@entry=0x7f1238f31008, rref_pointer_array=rref_pointer_array@entry=0x7f1238f35540, tables=0x7f1235efc278, wild_num=<optimized out>, fields=..., conds=<optimized out>, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=result@entry=0x7f1235dd2b38, unit=unit@entry=0x7f1238f34be0, select_lex=select_lex@entry=0x7f1238f352c8) at 10.0/sql/sql_select.cc:3294
      #11 0x000000000061d6b4 in handle_select (thd=0x7f1238f31008, lex=0x7f1238f34b18, result=0x7f1235dd2b38, setup_tables_done_option=0) at 10.0/sql/sql_select.cc:373
      #12 0x00000000005cd03b in execute_sqlcom_select (thd=thd@entry=0x7f1238f31008, all_tables=0x7f1235efc278) at 10.0/sql/sql_parse.cc:5269
      #13 0x00000000005d7d38 in mysql_execute_command (thd=thd@entry=0x7f1238f31008) at 10.0/sql/sql_parse.cc:2552
      #14 0x00000000005da55c in mysql_parse (parser_state=0x7f123fad6160, thd=0x7f1238f31008, rawbuf=<optimized out>, length=<optimized out>) at 10.0/sql/sql_parse.cc:6415
      #15 mysql_parse (thd=0x7f1238f31008, rawbuf=<optimized out>, length=76, parser_state=0x7f123fad6160) at 10.0/sql/sql_parse.cc:6336
      #16 0x00000000005dbc25 in dispatch_command (command=COM_QUERY, thd=0x7f1238f31008, packet=<optimized out>, packet_length=<optimized out>) at 10.0/sql/sql_parse.cc:1307
      #17 0x0000000000682bed in do_handle_one_connection (thd_arg=thd_arg@entry=0x7f1238f31008) at 10.0/sql/sql_connect.cc:1379
      #18 0x0000000000682cb0 in handle_one_connection (arg=arg@entry=0x7f1238f31008) at 10.0/sql/sql_connect.cc:1293
      #19 0x00000000009d0f24 in pfs_spawn_thread (arg=0x7f123d02d608) at 10.0/storage/perfschema/pfs.cc:1860
      #20 0x00007f123f6c3b50 in start_thread (arg=<optimized out>) at pthread_create.c:304
      #21 0x00007f123d97a20d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

      Test case is weird, but I couldn't remove anything else from it. All 3 selects seem to be important, as well as all multiple fields in the tables, even though they are not used.

      This particular test case only causes a crash on 10.0, but I am getting similar crashes on 5.5.40 as well.

      Test case

      CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=MyISAM;
       
      CREATE TABLE t2 (
        f1 DATE,
        f2 VARCHAR(1024),
        f3 VARCHAR(10),
        f4 DATE,
        f5 VARCHAR(10),
        f6 VARCHAR(10),
        f7 VARCHAR(10),
        f8 DATETIME,
        f9 INT,
        f10 VARCHAR(1024),
        f11 VARCHAR(1024),
        f12 INT,
        f13 VARCHAR(1024)
      ) ENGINE=MyISAM;
       
      CREATE OR REPLACE VIEW v2 AS SELECT * FROM t2;
       
      CREATE TABLE t3 (
        f1 VARCHAR(1024),
        f2 VARCHAR(1024),
        f3 DATETIME,
        f4 VARCHAR(10),
        f5 INT,
        f6 VARCHAR(10),
        f7 VARCHAR(1024),
        f8 VARCHAR(10),
        f9 INT,
        f10 DATE,
        f11 INT,
        f12 VARCHAR(1024),
        f13 VARCHAR(10),
        f14 DATE,
        f15 DATETIME
      ) ENGINE=MyISAM;
       
      CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t3;
       
      INSERT INTO t3 VALUES  
        ('FOO','foo','2000-08-04 00:00:00','one',1,'1','FOO','foo',1,'2004-05-09',1,'one','one','2001-12-07','2001-10-17 08:25:04'),  
        ('BAR','bar','2001-01-01 04:52:37','two',2,'2','BAR','bar',2,'2008-01-01',2,'two','two','2006-06-19','2002-01-01 08:22:49');
       
      CREATE TABLE t4 (f1 VARCHAR(10), f2 INT) ENGINE=MyISAM;
       
      SELECT * FROM t1;
       
      --error ER_BAD_FIELD_ERROR
      SELECT non_existing FROM v2;
       
      SELECT * FROM t1, v3, t4 WHERE v3.f1 = t4.f1 AND t4.f2 = 6 AND t1.pk = v3.f5;

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            5 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.