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

Assertion `0' failed in JOIN_CACHE::get_match_flag_by_pos

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.4, 10.5
    • 10.4, 10.5
    • Optimizer
    • None

    Description

      --source include/have_innodb.inc
       
      CREATE TABLE t1 (a CHAR(8)) ENGINE=InnoDB;
      INSERT INTO t1 VALUES ('foo');
       
      CREATE TABLE t2 (b VARCHAR(574)) ENGINE=InnoDB;
      INSERT INTO t2 VALUES ('bar'),('baz');
       
      CREATE TABLE t3 (e INT, d TEXT, PRIMARY KEY(e,d(8))) ENGINE=InnoDB;
      INSERT INTO t3 VALUES (1,'qux');
       
      CREATE TABLE t4 (f INT, KEY(f)) ENGINE=InnoDB;
      INSERT INTO t4 VALUES (1),(2);
       
      SET SESSION join_cache_level= 4;
      SET SESSION join_buffer_space_limit= 16384;
       
      SELECT DISTINCT a FROM t1 WHERE a IN (SELECT t2.b FROM t2 INNER JOIN t3 INNER JOIN t4 ON (t4.f = t3.e));
      

      10.4 c2ac0ce1

      mysqld: /data/src/10.4/sql/sql_join_cache.cc:1682: virtual JOIN_CACHE::Match_flag JOIN_CACHE::get_match_flag_by_pos(uchar*): Assertion `0' failed.
      201013  1:30:36 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007fb81a9fdf36 in __GI___assert_fail (assertion=0x559a41d96730 "0", file=0x559a41d967b0 "/data/src/10.4/sql/sql_join_cache.cc", line=1682, function=0x559a41d969e0 "virtual JOIN_CACHE::Match_flag JOIN_CACHE::get_match_flag_by_pos(uchar*)") at assert.c:101
      #8  0x0000559a4115a767 in JOIN_CACHE::get_match_flag_by_pos (this=0x7fb7c407aaf8, rec_ptr=0x7fb7c4070d44 "\375\375\003") at /data/src/10.4/sql/sql_join_cache.cc:1682
      #9  0x0000559a4115b0d8 in JOIN_CACHE::skip_if_not_needed_match (this=0x7fb7c407aaf8) at /data/src/10.4/sql/sql_join_cache.cc:2006
      #10 0x0000559a4115d85c in JOIN_CACHE_BNL::skip_next_candidate_for_match (this=0x7fb7c407aaf8, rec_ptr=0x7fb7c4070d44 "\375\375\003") at /data/src/10.4/sql/sql_join_cache.cc:3568
      #11 0x0000559a4115b8ff in JOIN_CACHE::join_matching_records (this=0x7fb7c407aaf8, skip_last=false) at /data/src/10.4/sql/sql_join_cache.cc:2292
      #12 0x0000559a4115b262 in JOIN_CACHE::join_records (this=0x7fb7c407aaf8, skip_last=false) at /data/src/10.4/sql/sql_join_cache.cc:2088
      #13 0x0000559a410045e9 in sub_select_cache (join=0x7fb7c4018520, join_tab=0x7fb7c4079690, end_of_records=true) at /data/src/10.4/sql/sql_select.cc:20186
      #14 0x0000559a410047fc in sub_select (join=0x7fb7c4018520, join_tab=0x7fb7c40792e8, end_of_records=true) at /data/src/10.4/sql/sql_select.cc:20357
      #15 0x0000559a410047fc in sub_select (join=0x7fb7c4018520, join_tab=0x7fb7c4078f40, end_of_records=true) at /data/src/10.4/sql/sql_select.cc:20357
      #16 0x0000559a410047fc in sub_select (join=0x7fb7c4018520, join_tab=0x7fb7c4078b98, end_of_records=true) at /data/src/10.4/sql/sql_select.cc:20357
      #17 0x0000559a41003f62 in do_select (join=0x7fb7c4018520, procedure=0x0) at /data/src/10.4/sql/sql_select.cc:19948
      #18 0x0000559a40fd8c07 in JOIN::exec_inner (this=0x7fb7c4018520) at /data/src/10.4/sql/sql_select.cc:4478
      #19 0x0000559a40fd7d36 in JOIN::exec (this=0x7fb7c4018520) at /data/src/10.4/sql/sql_select.cc:4260
      #20 0x0000559a40fd948a in mysql_select (thd=0x7fb7c4000d90, tables=0x7fb7c4013b40, wild_num=0, fields=..., conds=0x7fb7c4017990, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748609, result=0x7fb7c40184f8, unit=0x7fb7c4004cc0, select_lex=0x7fb7c4013578) at /data/src/10.4/sql/sql_select.cc:4695
      #21 0x0000559a40fc8e9b in handle_select (thd=0x7fb7c4000d90, lex=0x7fb7c4004c00, result=0x7fb7c40184f8, setup_tables_done_option=0) at /data/src/10.4/sql/sql_select.cc:410
      #22 0x0000559a40f8e738 in execute_sqlcom_select (thd=0x7fb7c4000d90, all_tables=0x7fb7c4013b40) at /data/src/10.4/sql/sql_parse.cc:6355
      #23 0x0000559a40f84d88 in mysql_execute_command (thd=0x7fb7c4000d90) at /data/src/10.4/sql/sql_parse.cc:3889
      #24 0x0000559a40f92743 in mysql_parse (thd=0x7fb7c4000d90, rawbuf=0x7fb7c4013448 "SELECT DISTINCT a FROM t1 WHERE a IN (SELECT t2.b FROM t2 INNER JOIN t3 INNER JOIN t4 ON (t4.f = t3.e))", length=103, parser_state=0x7fb8143c3550, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7896
      #25 0x0000559a40f7ec4e in dispatch_command (command=COM_QUERY, thd=0x7fb7c4000d90, packet=0x7fb7c40087a1 "", packet_length=103, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1834
      #26 0x0000559a40f7d4b6 in do_command (thd=0x7fb7c4000d90) at /data/src/10.4/sql/sql_parse.cc:1352
      #27 0x0000559a4110b2cb in do_handle_one_connection (connect=0x559a441ff350) at /data/src/10.4/sql/sql_connect.cc:1412
      #28 0x0000559a4110b014 in handle_one_connection (arg=0x559a441ff350) at /data/src/10.4/sql/sql_connect.cc:1316
      #29 0x0000559a41b23b4a in pfs_spawn_thread (arg=0x559a44108250) at /data/src/10.4/storage/perfschema/pfs.cc:1869
      #30 0x00007fb81af15609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #31 0x00007fb81aae9293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Reproducible on 10.4 and 10.5.
      The test case above does not fail on 10.3, but the plan is different there, so maybe with some adjustments to the query and/or data the failure can be reproduced on earlier versions as well.
      No obvious failure on a non-debug build.

      Plan on 10.4 (fails)

      EXPLAIN EXTENDED SELECT DISTINCT a FROM t1 WHERE a IN (SELECT t2.b FROM t2 INNER JOIN t3 INNER JOIN t4 ON (t4.f = t3.e));
      id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
      1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	1	100.00	Using temporary
      1	PRIMARY	t3	index	PRIMARY	PRIMARY	14	NULL	1	100.00	Using index
      1	PRIMARY	t4	hash_index	f	#hash#f:f	5:5	test.t3.e	2	50.00	Using index
      1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
      Warnings:
      Note	1003	select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where `test`.`t4`.`f` = `test`.`t3`.`e` and `test`.`t1`.`a` = `test`.`t2`.`b`
      

      Plan on 10.3 (does not fail)

      EXPLAIN EXTENDED SELECT DISTINCT a FROM t1 WHERE a IN (SELECT t2.b FROM t2 INNER JOIN t3 INNER JOIN t4 ON (t4.f = t3.e));
      id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
      1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	1	100.00	Using temporary
      1	PRIMARY	t3	index	PRIMARY	PRIMARY	14	NULL	1	100.00	Using index
      1	PRIMARY	t4	hash_index	f	#hash#f:f	5:5	test.t3.e	2	50.00	Using index
      1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where; FirstMatch(t1)
      Warnings:
      Note	1003	select distinct `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3` join `test`.`t4`) where `test`.`t4`.`f` = `test`.`t3`.`e` and `test`.`t1`.`a` = `test`.`t2`.`b`
      

      Attachments

        Activity

          People

            igor Igor Babaev
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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