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

Assertion `dict_col_get_fixed_size(f.col, not_redundant()) <= 768' failed in dict_table_t::init_instant

Details

    Description

      USE test;
      CREATE TABLE t (c INT);
      ALTER TABLE t ADD d INT FIRST;
      ALTER TABLE t ADD e CHAR(255) CHARACTER SET UTF32;
      

      Leads to:

      10.5.3 cfe5ee90c8e4b9dfa98a41fcd299197a59261be7

      mysqld: /test/10.5_dbg/storage/innobase/handler/handler0alter.cc:173: void dict_table_t::init_instant(const dict_table_t&): Assertion `dict_col_get_fixed_size(f.col, not_redundant()) <= 768' failed.
      

      10.5.3 cfe5ee90c8e4b9dfa98a41fcd299197a59261be7

      Core was generated by `/test/MD110520-mariadb-10.5.3-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
          at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
      [Current thread is 1 (Thread 0x146a4b686700 (LWP 1681418))]
      (gdb) bt
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
      #1  0x000055f30c918c11 in my_write_core (sig=sig@entry=6) at /test/10.5_dbg/mysys/stacktrace.c:518
      #2  0x000055f30c0bdf8d in handle_fatal_signal (sig=6) at /test/10.5_dbg/sql/signal_handler.cc:329
      #3  <signal handler called>
      #4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
      #5  0x0000146a49dca801 in __GI_abort () at abort.c:79
      #6  0x0000146a49dba39a in __assert_fail_base (fmt=0x146a49f417d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x55f30cd0c6b8 "dict_col_get_fixed_size(f.col, not_redundant()) <= 768", file=file@entry=0x55f30cd032e8 "/test/10.5_dbg/storage/innobase/handler/handler0alter.cc", line=line@entry=173, function=function@entry=0x55f30cd08420 <dict_table_t::init_instant(dict_table_t const&)::__PRETTY_FUNCTION__> "void dict_table_t::init_instant(const dict_table_t&)") at assert.c:92
      #7  0x0000146a49dba412 in __GI___assert_fail (assertion=assertion@entry=0x55f30cd0c6b8 "dict_col_get_fixed_size(f.col, not_redundant()) <= 768", file=file@entry=0x55f30cd032e8 "/test/10.5_dbg/storage/innobase/handler/handler0alter.cc", line=line@entry=173, function=function@entry=0x55f30cd08420 <dict_table_t::init_instant(dict_table_t const&)::__PRETTY_FUNCTION__> "void dict_table_t::init_instant(const dict_table_t&)") at assert.c:101
      #8  0x000055f30c4bbc9f in dict_table_t::init_instant (this=this@entry=0x146a28452598, table=...) at /test/10.5_dbg/storage/innobase/handler/handler0alter.cc:172
      #9  0x000055f30c4c629c in dict_table_t::instant_column (this=0x146a28452598, table=..., col_map=<optimized out>) at /test/10.5_dbg/storage/innobase/handler/handler0alter.cc:630
      #10 0x000055f30c4c6834 in ha_innobase_inplace_ctx::instant_column (this=this@entry=0x146a28475990) at /test/10.5_dbg/storage/innobase/handler/handler0alter.cc:1053
      #11 0x000055f30c4c6a8a in innobase_instant_try (ha_alter_info=ha_alter_info@entry=0x146a4b6819d0, ctx=ctx@entry=0x146a28475990, altered_table=altered_table@entry=0x146a4b681a70, table=table@entry=0x146a284f0088, trx=trx@entry=0x146a370033b0) at /test/10.5_dbg/storage/innobase/handler/handler0alter.cc:5632
      #12 0x000055f30c4ca27f in commit_try_norebuild (ha_alter_info=ha_alter_info@entry=0x146a4b6819d0, ctx=ctx@entry=0x146a28475990, altered_table=altered_table@entry=0x146a4b681a70, old_table=0x146a284f0088, trx=0x146a370033b0, table_name=<optimized out>) at /test/10.5_dbg/storage/innobase/handler/handler0alter.cc:10179
      #13 0x000055f30c4b6959 in ha_innobase::commit_inplace_alter_table (this=0x146a284394a0, altered_table=0x146a4b681a70, ha_alter_info=0x146a4b6819d0, commit=true) at /test/10.5_dbg/storage/innobase/handler/handler0alter.cc:10899
      #14 0x000055f30c0cc549 in handler::ha_commit_inplace_alter_table (this=0x146a284394a0, altered_table=altered_table@entry=0x146a4b681a70, ha_alter_info=ha_alter_info@entry=0x146a4b6819d0, commit=commit@entry=true) at /test/10.5_dbg/sql/handler.cc:4735
      #15 0x000055f30bedeb4c in mysql_inplace_alter_table (thd=thd@entry=0x146a28415088, table_list=0x146a284741b0, table=table@entry=0x146a284f0088, altered_table=altered_table@entry=0x146a4b681a70, ha_alter_info=ha_alter_info@entry=0x146a4b6819d0, inplace_supported=inplace_supported@entry=HA_ALTER_INPLACE_INSTANT, target_mdl_request=0x146a4b682830, alter_ctx=0x146a4b6836c0) at /test/10.5_dbg/sql/sql_table.cc:7920
      #16 0x000055f30beeaf17 in mysql_alter_table (thd=thd@entry=0x146a28415088, new_db=new_db@entry=0x146a28419940, new_name=new_name@entry=0x146a28419d48, create_info=create_info@entry=0x146a4b6842b0, table_list=<optimized out>, table_list@entry=0x146a284741b0, alter_info=alter_info@entry=0x146a4b6841e0, order_num=0, order=0x0, ignore=false, if_exists=false) at /test/10.5_dbg/sql/sql_table.cc:10442
      #17 0x000055f30bf6e7d0 in Sql_cmd_alter_table::execute (this=<optimized out>, thd=0x146a28415088) at /test/10.5_dbg/sql/sql_alter.cc:532
      #18 0x000055f30be19eda in mysql_execute_command (thd=thd@entry=0x146a28415088) at /test/10.5_dbg/sql/sql_parse.cc:5912
      #19 0x000055f30be21804 in mysql_parse (thd=thd@entry=0x146a28415088, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x146a4b6853e0, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:7957
      #20 0x000055f30be0dffd in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x146a28415088, packet=packet@entry=0x146a28467089 "ALTER TABLE t ADD e CHAR(255) CHARACTER SET UTF32", packet_length=packet_length@entry=49, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:1839
      #21 0x000055f30be0c8cc in do_command (thd=0x146a28415088) at /test/10.5_dbg/sql/sql_parse.cc:1358
      #22 0x000055f30bf6699d in do_handle_one_connection (connect=<optimized out>, connect@entry=0x146a2a4433a8, put_in_cache=put_in_cache@entry=true) at /test/10.5_dbg/sql/sql_connect.cc:1411
      #23 0x000055f30bf670b9 in handle_one_connection (arg=arg@entry=0x146a2a4433a8) at /test/10.5_dbg/sql/sql_connect.cc:1313
      #24 0x000055f30c3c510a in pfs_spawn_thread (arg=0x146a49045888) at /test/10.5_dbg/storage/perfschema/pfs.cc:2201
      #25 0x0000146a4aaad6db in start_thread (arg=0x146a4b686700) at pthread_create.c:463
      #26 0x0000146a49eab88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 10.4.13 (dbg), 10.5.2 (dbg), 10.5.3 (dbg)

      Bug confirmed not present in:
      MariaDB: 10.1.45 (dbg), 10.1.45 (opt), 10.2.32 (dbg), 10.2.32 (opt), 10.3.23 (dbg), 10.3.23 (opt), 10.4.13 (opt), 10.5.2 (opt), 10.5.3 (opt), 10.5.4 (dbg), 10.5.4 (opt)
      MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.47 (dbg), 5.6.47 (opt), 5.7.29 (dbg), 5.7.29 (opt), 8.0.19 (dbg), 8.0.19 (opt)

      Note that MariaDB 10.5.4 dbg does not crash.

      MariaDB 10.3.23 (debug):

      10.3.23 811e4409ce587bc4b693cc0262bccccacc0238fb

      10.3.23>USE test;
      Database changed
      10.3.23>CREATE TABLE t (c INT);
      Query OK, 0 rows affected (0.012 sec)
      10.3.23>ALTER TABLE t ADD d INT FIRST;
      Query OK, 0 rows affected (0.033 sec)
      Records: 0  Duplicates: 0  Warnings: 0
      10.3.23>ALTER TABLE t ADD e CHAR(255) CHARACTER SET UTF32;
      Query OK, 0 rows affected (0.004 sec)
      Records: 0  Duplicates: 0  Warnings: 0
      

      Attachments

        Issue Links

          Activity

            Roel Roel Van de Paar added a comment - - edited

            Also see MDEV-22771. Issue may or may not be charset related. Set to critical until analyzed; feel free to adjust as needed.

            Roel Roel Van de Paar added a comment - - edited Also see MDEV-22771 . Issue may or may not be charset related. Set to critical until analyzed; feel free to adjust as needed.

            marko, kevg, can you please check this issue? Thanks.

            bar Alexander Barkov added a comment - marko , kevg , can you please check this issue? Thanks.

            This turned out to be a bogus debug assertion.

            I can repeat this on 10.4 with an even simpler test case (basically any CREATE TABLE…ENGINE=InnoDB followed by the ALTER TABLE):

            --source include/have_innodb.inc
            CREATE TABLE t (c CHAR(255) CHARACTER SET UTF32) ENGINE=InnoDB;
            ALTER TABLE t ADD e CHAR(255) CHARACTER SET UTF32 FIRST;
            DROP TABLE t;
            

            For the initially created column c the following will hold in handler::ha_prepare_inplace_alter_table():

            10.4 f843e215f3f640de377d8fd60e85bb372fb138fd

            (rr) p *((ha_innobase*)this)->m_prebuilt.table.indexes.start.fields[3].col
            $17 = {prtype = 3932414, mtype = 13, len = 1020, mbminlen = 4, mbmaxlen = 4, 
              ind = 0, ord_part = 0, max_prefix = 0, def_val = {data = 0x0, 
                len = 4294967294}}
            

            Note the len=1020 that corresponds to 4×255. This would also hold for f.col.len for the column e in dict_table_t::init_instant(), triggering the debug assertion failure.
            I think that in MDEV-15562 I was trying to be consistent with dict_index_add_col() in that debug assertion, but I failed to notice that the logic is being applied to dict_index_t::fields[] and not dict_table_t::cols[]:

            	/* Long fixed-length fields that need external storage are treated as
            	variable-length fields, so that the extern flag can be embedded in
            	the length word. */
             
            	if (field->fixed_len > DICT_MAX_FIXED_COL_LEN) {
            		field->fixed_len = 0;
            	}
            

            marko Marko Mäkelä added a comment - This turned out to be a bogus debug assertion. I can repeat this on 10.4 with an even simpler test case (basically any CREATE TABLE…ENGINE=InnoDB followed by the ALTER TABLE ): --source include/have_innodb.inc CREATE TABLE t (c CHAR (255) CHARACTER SET UTF32) ENGINE=InnoDB; ALTER TABLE t ADD e CHAR (255) CHARACTER SET UTF32 FIRST ; DROP TABLE t; For the initially created column c the following will hold in handler::ha_prepare_inplace_alter_table() : 10.4 f843e215f3f640de377d8fd60e85bb372fb138fd (rr) p *((ha_innobase*)this)->m_prebuilt.table.indexes.start.fields[3].col $17 = {prtype = 3932414, mtype = 13, len = 1020, mbminlen = 4, mbmaxlen = 4, ind = 0, ord_part = 0, max_prefix = 0, def_val = {data = 0x0, len = 4294967294}} Note the len=1020 that corresponds to 4×255. This would also hold for f.col.len for the column e in dict_table_t::init_instant() , triggering the debug assertion failure. I think that in MDEV-15562 I was trying to be consistent with dict_index_add_col() in that debug assertion, but I failed to notice that the logic is being applied to dict_index_t::fields[] and not dict_table_t::cols[] : /* Long fixed-length fields that need external storage are treated as variable-length fields, so that the extern flag can be embedded in the length word. */   if (field->fixed_len > DICT_MAX_FIXED_COL_LEN) { field->fixed_len = 0; }

            This bogus debug assertion was not present in release builds.

            marko Marko Mäkelä added a comment - This bogus debug assertion was not present in release builds.

            People

              marko Marko Mäkelä
              Roel Roel Van de Paar
              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.