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

Segfault on CREATE TABLE with explicit FTS_DOC_ID_INDEX by multiple fields

    XMLWordPrintable

Details

    Description

      Reproduce

      --source include/have_innodb.inc
       
      --error ER_WRONG_NAME_FOR_INDEX
      create table t1 (
        f1 int, f2 text,
        FTS_DOC_ID bigint unsigned not null,
        unique key FTS_DOC_ID_INDEX(FTS_DOC_ID, f1),
        fulltext (f2))
      engine=innodb;
      

      Result

      #3  <signal handler called>
      #4  0x0000000000fcd837 in fts_drop_all_index_tables (trx=0x7f22ea2d0218, fts=0x0) at /home/midenok/src/mariadb/10.2/src/storage/innobase/fts/fts0fts.cc:1673
      #5  0x0000000000fcbbd2 in fts_drop_tables (trx=0x7f22ea2d0218, table=0x7f2298006600) at /home/midenok/src/mariadb/10.2/src/storage/innobase/fts/fts0fts.cc:1713
      #6  0x0000000000d9ac3c in row_drop_ancillary_fts_tables (table=0x7f2298006600, trx=0x7f22ea2d0218) at /home/midenok/src/mariadb/10.2/src/storage/innobase/row/row0mysql.cc:3177
      #7  0x0000000000d97cad in row_drop_table_for_mysql (name=0x7f22e96ebf10 "test/t1", trx=0x7f22ea2d0218, sqlcom=SQLCOM_TRUNCATE, create_failed=true, nonatomic=false) at /home/midenok/src/mariadb/10.2/src/storage/
      innobase/row/row0mysql.cc:3707
      #8  0x0000000000c45b54 in ha_innobase::create (this=0x7f2298187ad0, name=0x7f22e96ef690 "./test/t1", form=0x7f22e96ec988, create_info=0x7f22e96efc20, file_per_table=true, trx=0x7f22ea2d0218) at /home/midenok/src/mariadb/10.2/src/storage/innobase/handler/ha_innodb.cc:13090
      #9  0x0000000000c290cf in ha_innobase::create (this=0x7f2298187ad0, name=0x7f22e96ef690 "./test/t1", form=0x7f22e96ec988, create_info=0x7f22e96efc20) at /home/midenok/src/mariadb/10.2/src/storage/innobase/handler/ha_innodb.cc:13137
      #10 0x00000000009ce213 in handler::ha_create (this=0x7f2298187ad0, name=0x7f22e96ef690 "./test/t1", form=0x7f22e96ec988, info_arg=0x7f22e96efc20) at /home/midenok/src/mariadb/10.2/src/sql/handler.cc:4507
      #11 0x00000000009cf48f in ha_create_table (thd=0x7f2298000d28, path=0x7f22e96ef690 "./test/t1", db=0x7f2298012148 "test", table_name=0x7f2298011ae0 "t1", create_info=0x7f22e96efc20, frm=0x7f22e96ef680) at /home/midenok/src/mariadb/10.2/src/sql/handler.cc:4879
      #12 0x000000000085b52b in rea_create_table (thd=0x7f2298000d28, frm=0x7f22e96ef680, path=0x7f22e96ef690 "./test/t1", db=0x7f2298012148 "test", table_name=0x7f2298011ae0 "t1", create_info=0x7f22e96efc20, file=0x7f2298012bf0, no_ha_create_table=false) at /home/midenok/src/mariadb/10.2/src/sql/unireg.cc:429
      #13 0x00000000007f5312 in create_table_impl (thd=0x7f2298000d28, orig_db=0x7f2298012148 "test", orig_table_name=0x7f2298011ae0 "t1", db=0x7f2298012148 "test", table_name=0x7f2298011ae0 "t1", path=0x7f22e96ef690 "./test/t1", options=..., create_info=0x7f22e96efc20, alter_info=0x7f22e96efb78, create_table_mode=0, is_trans=0x7f22e96ef9b7, key_info=0x7f22e96ef8a0, key_count=0x7f22e96ef89c, frm=0x7f22e96ef680) at /home/midenok/src/mariadb/10.2/src/sql/sql_table.cc:4960
      #14 0x00000000007f46c6 in mysql_create_table_no_lock (thd=0x7f2298000d28, db=0x7f2298012148 "test", table_name=0x7f2298011ae0 "t1", create_info=0x7f22e96efc20, alter_info=0x7f22e96efb78, is_trans=0x7f22e96ef9b7, create_table_mode=0) at /home/midenok/src/mariadb/10.2/src/sql/sql_table.cc:5070
      #15 0x00000000007f5ab1 in mysql_create_table (thd=0x7f2298000d28, create_table=0x7f2298011b30, create_info=0x7f22e96efc20, alter_info=0x7f22e96efb78) at /home/midenok/src/mariadb/10.2/src/sql/sql_table.cc:5135
      #16 0x00000000008085cf in Sql_cmd_create_table::execute (this=0x7f2298011b10, thd=0x7f2298000d28) at /home/midenok/src/mariadb/10.2/src/sql/sql_table.cc:10979
      #17 0x0000000000710dfc in mysql_execute_command (thd=0x7f2298000d28) at /home/midenok/src/mariadb/10.2/src/sql/sql_parse.cc:5993
      #18 0x0000000000704a00 in mysql_parse (thd=0x7f2298000d28, rawbuf=0x7f2298011948 "create table t1 (\nf1 int, f2 text,\nFTS_DOC_ID bigint unsigned not null,\nunique key FTS_DOC_ID_INDEX(FTS_DOC_ID, f1),\nfulltext (f2))\nengine=innodb", length=145, parser_state=0x7f22e96f25f0, is_com_multi=false, is_next_command=false) at /home/midenok/src/mariadb/10.2/src/sql/sql_parse.cc:7762
      

      Cause

      table->fts is freed:

      #0  fts_free (table=0x7f51f001b3f0) at /home/midenok/src/mariadb/10.3/src/storage/innobase/fts/fts0fts.cc:5402
      #1  0x0000000000daa62f in create_table_info_t::create_table (this=0x7f52340ec4a0, create_fk=true) at /home/midenok/src/mariadb/10.3/src/storage/innobase/handler/ha_innodb.cc:12373
      #2  0x0000000000dcb69c in ha_innobase::create (this=0x7f51f001a770, name=0x7f52340effe0 "./test/t1", form=0x7f52340ed1d0, create_info=0x7f52340f05e8, file_per_table=true, trx=0x7f525dbb3178) at /home/midenok/src/mariadb/10.3/src/storage/innobase/handler/ha_innodb.cc:12860
      

      12353                   ret = innobase_fts_check_doc_id_index_in_def(
      12354                           m_form->s->keys, m_form->key_info);
      12355
      12356                   switch (ret) {
      12357                   case FTS_INCORRECT_DOC_ID_INDEX:
      12358                           push_warning_printf(m_thd,
      12359                                               Sql_condition::WARN_LEVEL_WARN,
      12360                                               ER_WRONG_NAME_FOR_INDEX,
      12361                                               " InnoDB: Index name %s is reserved"
      12362                                               " for the unique index on"
      12363                                               " FTS_DOC_ID column for FTS"
      12364                                               " Document ID indexing"
      12365                                               " on table %s. Please check"
      12366                                               " the index definition to"
      12367                                               " make sure it is of correct"
      12368                                               " type\n",
      12369                                               FTS_DOC_ID_INDEX_NAME,
      12370                                               m_table->name.m_name);
      12371
      12372                           if (m_table->fts) {
      12373                                   fts_free(m_table);
      12374                           }
      12375
      12376                           my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0),
      12377                                    FTS_DOC_ID_INDEX_NAME);
      12378                           DBUG_RETURN(-1);
      

      and then accessed:

      #0  0x00000000012337c7 in fts_drop_all_index_tables (trx=0x7f525dbb3178, fts=0x0) at /home/midenok/src/mariadb/10.3/src/storage/innobase/fts/fts0fts.cc:1672
      #1  0x0000000001231742 in fts_drop_tables (trx=0x7f525dbb3178, table=0x7f51f001b3f0) at /home/midenok/src/mariadb/10.3/src/storage/innobase/fts/fts0fts.cc:1712
      #2  0x0000000000f86444 in row_drop_ancillary_fts_tables (table=0x7f51f001b3f0, trx=0x7f525dbb3178) at /home/midenok/src/mariadb/10.3/src/storage/innobase/row/row0mysql.cc:3256
      #3  0x0000000000f82c88 in row_drop_table_for_mysql (name=0x7f52340ec730 "test/t1", trx=0x7f525dbb3178, sqlcom=SQLCOM_TRUNCATE, create_failed=true, nonatomic=false) at /home/midenok/src/mariadb/10.3/src/storage/innobase/row/row0mysql.cc:3729
      #4  0x0000000000dcb726 in ha_innobase::create (this=0x7f51f001a770, name=0x7f52340effe0 "./test/t1", form=0x7f52340ed1d0, create_info=0x7f52340f05e8, file_per_table=true, trx=0x7f525dbb3178) at /home/midenok/src/mariadb/10.3/src/storage/innobase/handler/ha_innodb.cc:12866
      

      1711            if (error == DB_SUCCESS) {
      1712                    error = fts_drop_all_index_tables(trx, table->fts);
      1713            }
      

      Fix

      --- a/storage/innobase/fts/fts0fts.cc
      +++ b/storage/innobase/fts/fts0fts.cc
      @@ -1708,7 +1708,7 @@ fts_drop_tables(
       
              error = fts_drop_common_tables(trx, &fts_table);
       
      -       if (error == DB_SUCCESS) {
      +       if (error == DB_SUCCESS && table->fts) {
                      error = fts_drop_all_index_tables(trx, table->fts);
              }
      

      Attachments

        Issue Links

          Activity

            People

              midenok Aleksey Midenkov
              midenok Aleksey Midenkov
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.