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

Assertion `(templ->is_virtual && !field) || (field && field->prefix_len ? field->prefix_len == len : templ->mysql_col_len == len)' failed row_sel_field_store_in_mysql_format_func

Details

    Description

      Note: I'm filing it for 10.4 because it's the only version I can reproduce it with; but the failure depends on the execution plan. I can get rid of the failure by setting rowid_filter=off in optimizer_switch on 10.4, but I can't do the reverse on 10.3, so I have no information whether the problem exists in previous version.

      Note: Run with --repeat=N. The test case appears deterministic, but the failure is still sporadic. It usually fails for me withing first 1-2 attempts, but it can vary on different machines and builds.

      --source include/have_innodb.inc
       
      SET @stats.save= @@innodb_stats_persistent;
      SET GLOBAL innodb_stats_persistent= ON;
       
      CREATE TABLE t1 ( 
        a CHAR(100),
        pk INTEGER AUTO_INCREMENT,
        b BIT(8),
        c CHAR(115) AS (a) VIRTUAL,
        PRIMARY KEY(pk),
        KEY(c),
        KEY(b)
      ) ENGINE=InnoDB;
      INSERT INTO t1 (a,b) VALUES ('foo',b'0'),('',NULL),(NULL,b'1');
       
      CREATE TABLE t2 (f CHAR(100)) ENGINE=InnoDB;
       
      SELECT t1a.* FROM t1 AS t1a JOIN t1 AS t1b LEFT JOIN t2  ON (f = t1b.a) WHERE t1a.b >= 0 AND t1a.c = t1b.a;
       
      # Cleanup
      DROP TABLE t1, t2;
      SET GLOBAL innodb_stats_persistent= @stats.save;
      

      10.4 6d68a346

      mysqld: /data/src/10.4/storage/innobase/row/row0sel.cc:2854: void row_sel_field_store_in_mysql_format_func(byte*, const mysql_row_templ_t*, const dict_index_t*, ulint, const byte*, ulint): Assertion `(templ->is_virtual && !field) || (field && field->prefix_len ? field->prefix_len == len : templ->mysql_col_len == len)' failed.
      190313 15:11:45 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007fb2b35aeee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
      #8  0x0000564f5f0195f8 in row_sel_field_store_in_mysql_format_func (dest=0x7fb2641a1241 ' ' <repeats 100 times>, "\003", templ=0x7fb26406cac0, index=0x7fb26414feb8, field_no=1, data=0x7fb2ad0a40f1 "\200", len=4) at /data/src/10.4/storage/innobase/row/row0sel.cc:2851
      #9  0x0000564f5f019d14 in row_sel_store_mysql_field (mysql_rec=0x7fb2641a1240 "\373", ' ' <repeats 100 times>, "\003", prebuilt=0x7fb264152508, rec=0x7fb2ad0a407e "foo", ' ' <repeats 112 times>, "\200", index=0x7fb26414feb8, offsets=0x7fb2ac8d5220, field_no=1, templ=0x7fb26406cac0) at /data/src/10.4/storage/innobase/row/row0sel.cc:3006
      #10 0x0000564f5f01bdab in row_search_idx_cond_check (mysql_rec=0x7fb2641a1240 "\373", ' ' <repeats 100 times>, "\003", prebuilt=0x7fb264152508, rec=0x7fb2ad0a407e "foo", ' ' <repeats 112 times>, "\200", offsets=0x7fb2ac8d5220) at /data/src/10.4/storage/innobase/row/row0sel.cc:3888
      #11 0x0000564f5f01f6a9 in row_search_mvcc (buf=0x7fb2641a1240 "\373", ' ' <repeats 100 times>, "\003", mode=PAGE_CUR_GE, prebuilt=0x7fb264152508, match_mode=1, direction=0) at /data/src/10.4/storage/innobase/row/row0sel.cc:5205
      #12 0x0000564f5ee7d7f1 in ha_innobase::index_read (this=0x7fb264151518, buf=0x7fb2641a1240 "\373", ' ' <repeats 100 times>, "\003", key_ptr=0x7fb26407ca70 "", key_len=116, find_flag=HA_READ_KEY_EXACT) at /data/src/10.4/storage/innobase/handler/ha_innodb.cc:9360
      #13 0x0000564f5eb4b404 in handler::index_read_map (this=0x7fb264151518, buf=0x7fb2641a1240 "\373", ' ' <repeats 100 times>, "\003", key=0x7fb26407ca70 "", keypart_map=1, find_flag=HA_READ_KEY_EXACT) at /data/src/10.4/sql/handler.h:3594
      #14 0x0000564f5eb3d2b7 in handler::ha_index_read_map (this=0x7fb264151518, buf=0x7fb2641a1240 "\373", ' ' <repeats 100 times>, "\003", key=0x7fb26407ca70 "", keypart_map=1, find_flag=HA_READ_KEY_EXACT) at /data/src/10.4/sql/handler.cc:3040
      #15 0x0000564f5e86d891 in join_read_always_key (tab=0x7fb26407bf18) at /data/src/10.4/sql/sql_select.cc:20776
      #16 0x0000564f5e86bd5d in sub_select (join=0x7fb264019718, join_tab=0x7fb26407bf18, end_of_records=false) at /data/src/10.4/sql/sql_select.cc:20015
      #17 0x0000564f5e86c4cb in evaluate_join_record (join=0x7fb264019718, join_tab=0x7fb26407bb50, error=0) at /data/src/10.4/sql/sql_select.cc:20238
      #18 0x0000564f5e86bdbf in sub_select (join=0x7fb264019718, join_tab=0x7fb26407bb50, end_of_records=false) at /data/src/10.4/sql/sql_select.cc:20018
      #19 0x0000564f5e86b2ed in do_select (join=0x7fb264019718, procedure=0x0) at /data/src/10.4/sql/sql_select.cc:19556
      #20 0x0000564f5e841da9 in JOIN::exec_inner (this=0x7fb264019718) at /data/src/10.4/sql/sql_select.cc:4371
      #21 0x0000564f5e840f50 in JOIN::exec (this=0x7fb264019718) at /data/src/10.4/sql/sql_select.cc:4153
      #22 0x0000564f5e842602 in mysql_select (thd=0x7fb264000b00, tables=0x7fb264015bd8, wild_num=1, fields=..., conds=0x7fb264018c60, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7fb2640196f0, unit=0x7fb264004a28, select_lex=0x7fb264015608) at /data/src/10.4/sql/sql_select.cc:4585
      #23 0x0000564f5e832b7a in handle_select (thd=0x7fb264000b00, lex=0x7fb264004960, result=0x7fb2640196f0, setup_tables_done_option=0) at /data/src/10.4/sql/sql_select.cc:424
      #24 0x0000564f5e7fbf4b in execute_sqlcom_select (thd=0x7fb264000b00, all_tables=0x7fb264015bd8) at /data/src/10.4/sql/sql_parse.cc:6651
      #25 0x0000564f5e7f1206 in mysql_execute_command (thd=0x7fb264000b00) at /data/src/10.4/sql/sql_parse.cc:3888
      #26 0x0000564f5e7ffe8b in mysql_parse (thd=0x7fb264000b00, rawbuf=0x7fb2640154c8 "SELECT t1a.* FROM t1 AS t1a JOIN t1 AS t1b LEFT JOIN t2  ON (f = t1b.a) WHERE t1a.b >= 0 AND t1a.c = t1b.a", length=106, parser_state=0x7fb2ac8d7180, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:8204
      #27 0x0000564f5e7eb4cd in dispatch_command (command=COM_QUERY, thd=0x7fb264000b00, packet=0x7fb264139ff1 "", packet_length=106, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1829
      #28 0x0000564f5e7e9cb3 in do_command (thd=0x7fb264000b00) at /data/src/10.4/sql/sql_parse.cc:1358
      #29 0x0000564f5e9639e5 in do_handle_one_connection (connect=0x564f61f954f0) at /data/src/10.4/sql/sql_connect.cc:1399
      #30 0x0000564f5e963756 in handle_one_connection (arg=0x564f61f954f0) at /data/src/10.4/sql/sql_connect.cc:1302
      #31 0x0000564f5ee59253 in pfs_spawn_thread (arg=0x564f61fdb360) at /data/src/10.4/storage/perfschema/pfs.cc:1862
      #32 0x00007fb2b5285494 in start_thread (arg=0x7fb2ac8d8700) at pthread_create.c:333
      #33 0x00007fb2b366b93f in clone () from /lib/x86_64-linux-gnu/libc.so.6
      

      Attachments

        Issue Links

          Activity

            alice Alice Sherepa added a comment - - edited

            still reproducible on 10.4-10.11, not repeatable on 11.0+, but that is probably because of the change of the execution plan:
            10.4-10.11:

            explain extended
            SELECT t1a.* FROM t1 AS t1a JOIN t1 AS t1b LEFT JOIN t2  ON (f = t1b.a) WHERE t1a.b >= 0 AND t1a.c = t1b.a;
            id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
            1	SIMPLE	t1b	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
            1	SIMPLE	t1a	ref|filter	c,b	c|b	116|2	test.t1b.a	1 (67%)	66.67	Using where; Using rowid filter
            1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where; Using join buffer (flat, BNL join)
            Warnings:
            Note	1003	select `test`.`t1a`.`a` AS `a`,`test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`b` AS `b`,`test`.`t1a`.`c` AS `c` from `test`.`t1` `t1a` join `test`.`t1` `t1b` left join `test`.`t2` on(`test`.`t2`.`f` = `test`.`t1b`.`a`) where `test`.`t1a`.`b` >= 0 and `test`.`t1a`.`c` = `test`.`t1b`.`a`
            DROP TABLE t1, t2;
            
            

            11.0+

            explain extended
            SELECT t1a.* FROM t1 AS t1a JOIN t1 AS t1b LEFT JOIN t2  ON (f = t1b.a) WHERE t1a.b >= 0 AND t1a.c = t1b.a;
            id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
            1	SIMPLE	t1b	ALL	NULL	NULL	NULL	NULL	3	100.00	
            1	SIMPLE	t1a	range	c,b	b	2	NULL	2	33.33	Using index condition; Using where; Using join buffer (flat, BNL join)
            1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where; Using join buffer (incremental, BNL join)
            Warnings:
            Note	1003	select `test`.`t1a`.`a` AS `a`,`test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`b` AS `b`,`test`.`t1a`.`c` AS `c` from `test`.`t1` `t1a` join `test`.`t1` `t1b` left join `test`.`t2` on(`test`.`t2`.`f` = `test`.`t1b`.`a`) where `test`.`t1a`.`b` >= 0 and `test`.`t1a`.`c` = `test`.`t1b`.`a`
            

            Please check also MDEV-33259 - there also the crash on non-debug build

            alice Alice Sherepa added a comment - - edited still reproducible on 10.4-10.11, not repeatable on 11.0+, but that is probably because of the change of the execution plan: 10.4-10.11: explain extended SELECT t1a.* FROM t1 AS t1a JOIN t1 AS t1b LEFT JOIN t2 ON (f = t1b.a) WHERE t1a.b >= 0 AND t1a.c = t1b.a; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1b ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t1a ref|filter c,b c|b 116|2 test.t1b.a 1 (67%) 66.67 Using where; Using rowid filter 1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join) Warnings: Note 1003 select `test`.`t1a`.`a` AS `a`,`test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`b` AS `b`,`test`.`t1a`.`c` AS `c` from `test`.`t1` `t1a` join `test`.`t1` `t1b` left join `test`.`t2` on(`test`.`t2`.`f` = `test`.`t1b`.`a`) where `test`.`t1a`.`b` >= 0 and `test`.`t1a`.`c` = `test`.`t1b`.`a` DROP TABLE t1, t2; 11.0+ explain extended SELECT t1a.* FROM t1 AS t1a JOIN t1 AS t1b LEFT JOIN t2 ON (f = t1b.a) WHERE t1a.b >= 0 AND t1a.c = t1b.a; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1b ALL NULL NULL NULL NULL 3 100.00 1 SIMPLE t1a range c,b b 2 NULL 2 33.33 Using index condition; Using where; Using join buffer (flat, BNL join) 1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (incremental, BNL join) Warnings: Note 1003 select `test`.`t1a`.`a` AS `a`,`test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`b` AS `b`,`test`.`t1a`.`c` AS `c` from `test`.`t1` `t1a` join `test`.`t1` `t1b` left join `test`.`t2` on(`test`.`t2`.`f` = `test`.`t1b`.`a`) where `test`.`t1a`.`b` >= 0 and `test`.`t1a`.`c` = `test`.`t1b`.`a` Please check also MDEV-33259 - there also the crash on non-debug build
            alice Alice Sherepa added a comment -

            fixed by d912a6369c

            commit d912a6369c6f7f8ba233ac88436d59f6e420c368 (HEAD)
            Author: mariadb-DebarunBanerjee <debarun.banerjee@mariadb.com>
            Date:   Thu Mar 14 18:59:47 2024 +0530
             
                MDEV-31154 Fatal InnoDB error or assertion `!is_v' failure upon multi-update with indexed virtual column
                MDEV-33558 Fatal error InnoDB: Clustered record field for column x not found
                
                This is issue is about row ID filtering used with index on virtual
                column(s). We hit debug assert and crash while building the record
                template in Innodb. The primary reason is that we try to force the code
                path to use the ICP path. With ICP, we don't support index with virtual
                column and we validate it while index condition is pushed.
                
                Simplify the code for building template to handle both ICP and Row ID
                filtering by skipping virtual columns.
            
            

            alice Alice Sherepa added a comment - fixed by d912a6369c commit d912a6369c6f7f8ba233ac88436d59f6e420c368 (HEAD) Author: mariadb-DebarunBanerjee <debarun.banerjee@mariadb.com> Date: Thu Mar 14 18:59:47 2024 +0530   MDEV-31154 Fatal InnoDB error or assertion `!is_v' failure upon multi-update with indexed virtual column MDEV-33558 Fatal error InnoDB: Clustered record field for column x not found This is issue is about row ID filtering used with index on virtual column(s). We hit debug assert and crash while building the record template in Innodb. The primary reason is that we try to force the code path to use the ICP path. With ICP, we don't support index with virtual column and we validate it while index condition is pushed. Simplify the code for building template to handle both ICP and Row ID filtering by skipping virtual columns.

            People

              nikitamalyavin Nikita Malyavin
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.