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

Server crashes in row_make_new_pathname | ALTER TABLE ENGINE INNODB after DISCARD TABLESPACE

Details

    Description

      CREATE TABLE t (a INT) ENGINE=INNODB;
      ALTER TABLE t DISCARD TABLESPACE;
      ALTER TABLE t ENGINE INNODB;
      

      Leads to

      Exception thrown at 0x00007FF7F7C69C13 in mysqld.exe: 0xC0000005: Access violation reading location 0x0000000000000068.
      mysqld.exe!row_make_new_pathname(dict_table_t * table, const char * new_name) Line 4280 (d:\maria\server\storage\innobase\row\row0merge.cc:4280)
      mysqld.exe!row_merge_rename_tables_dict(dict_table_t * old_table, dict_table_t * new_table, const char * tmp_name, trx_t * trx) Line 4335 (d:\maria\server\storage\innobase\row\row0merge.cc:4335)
      mysqld.exe!commit_try_rebuild(Alter_inplace_info * ha_alter_info, ha_innobase_inplace_ctx * ctx, TABLE * altered_table, const TABLE * old_table, trx_t * trx, const char * table_name) Line 8508 (d:\maria\server\storage\innobase\handler\handler0alter.cc:8508)
      mysqld.exe!ha_innobase::commit_inplace_alter_table(TABLE * altered_table, Alter_inplace_info * ha_alter_info, bool commit) Line 9473 (d:\maria\server\storage\innobase\handler\handler0alter.cc:9473)
      mysqld.exe!handler::ha_commit_inplace_alter_table(TABLE * altered_table, Alter_inplace_info * ha_alter_info, bool commit) Line 4578 (d:\maria\server\sql\handler.cc:4578)
      mysqld.exe!mysql_inplace_alter_table(THD * thd, TABLE_LIST * table_list, TABLE * table, TABLE * altered_table, Alter_inplace_info * ha_alter_info, enum_alter_inplace_result inplace_supported, MDL_request * target_mdl_request, Alter_table_ctx * alter_ctx) Line 7678 (d:\maria\server\sql\sql_table.cc:7678)
      mysqld.exe!mysql_alter_table(THD * thd, const st_mysql_const_lex_string * new_db, const st_mysql_const_lex_string * new_name, HA_CREATE_INFO * create_info, TABLE_LIST * table_list, Alter_info * alter_info, unsigned int order_num, st_order * order, bool ignore) Line 9918 (d:\maria\server\sql\sql_table.cc:9918)
      mysqld.exe!Sql_cmd_alter_table::execute(THD * thd) Line 500 (d:\maria\server\sql\sql_alter.cc:500)
      mysqld.exe!mysql_execute_command(THD * thd) Line 6030 (d:\maria\server\sql\sql_parse.cc:6030)
      mysqld.exe!mysql_parse(THD * thd, char * rawbuf, unsigned int length, Parser_state * parser_state, bool is_com_multi, bool is_next_command) Line 7817 (d:\maria\server\sql\sql_parse.cc:7817)
      mysqld.exe!dispatch_command(enum_server_command command, THD * thd, char * packet, unsigned int packet_length, bool is_com_multi, bool is_next_command) Line 1858 (d:\maria\server\sql\sql_parse.cc:1858)
      mysqld.exe!do_command(THD * thd) Line 1401 (d:\maria\server\sql\sql_parse.cc:1401)
      mysqld.exe!threadpool_process_request(THD * thd) Line 359 (d:\maria\server\sql\threadpool_common.cc:359)
      mysqld.exe!tp_callback(TP_connection * c) Line 186 (d:\maria\server\sql\threadpool_common.cc:186)
      mysqld.exe!tp_callback(_TP_CALLBACK_INSTANCE * instance, void * context) Line 376 (d:\maria\server\sql\threadpool_win.cc:376)
      mysqld.exe!work_callback(_TP_CALLBACK_INSTANCE * instance, void * context, _TP_WORK * work) Line 450 (d:\maria\server\sql\threadpool_win.cc:450)
      ntdll.dll!00007ffc3c03081d() (Unknown Source:0)
      ntdll.dll!00007ffc3c0345b4() (Unknown Source:0)
      kernel32.dll!00007ffc3bd67bd4() (Unknown Source:0)
      ntdll.dll!00007ffc3c06ce51() (Unknown Source:0)
      

      In 10.3, 10.4, 10.5. Not found in 10.2.

      Result of above queries in 10.2:

      create table t(a INT) ENGINE = INNODB;
      Query OK, 0 rows affected (0.32 sec)
       
      mysql> ALTER TABLE t DISCARD TABLESPACE;
      Query OK, 0 rows affected (0.09 sec)
       
      ALTER TABLE t ENGINE INNODB;
      Query OK, 0 rows affected, 1 warning (0.33 sec)
      Records: 0  Duplicates: 0  Warnings: 1
       
      show warnings;
      +---------+------+---------------------------------------------+
      | Level   | Code | Message                                     |
      +---------+------+---------------------------------------------+
      | Warning | 1814 | Tablespace has been discarded for table `t` |
      +---------+------+---------------------------------------------+
       
      select * from t;
      ERROR 1814 (HY000): Tablespace has been discarded for table `t`
      

      Attachments

        Issue Links

          Activity

            shihche Shihao Chen added a comment - - edited

            in row_merge_rename_tables_dict@row0merge.cc:

            /* Update SYS_TABLESPACES and SYS_DATAFILES if the old table being
            renamed is a single-table tablespace, which must be implicitly
            renamed along with the table. */
            if (err == DB_SUCCESS
                && old_table->space_id) {
            	/* Make pathname to update SYS_DATAFILES. */
            	char* tmp_path = row_make_new_pathname(old_table, tmp_name);
            

            old_table->space_id and old_table->space->chain.start->name are used in row_make_new_pathname but only old_table->space_id is checked.
            Discarded tables seem to have non-zero space_id and NULL space. Are we missing a NULL check here?

            shihche Shihao Chen added a comment - - edited in row_merge_rename_tables_dict@row0merge.cc: /* Update SYS_TABLESPACES and SYS_DATAFILES if the old table being renamed is a single-table tablespace, which must be implicitly renamed along with the table. */ if (err == DB_SUCCESS && old_table->space_id) { /* Make pathname to update SYS_DATAFILES. */ char* tmp_path = row_make_new_pathname(old_table, tmp_name); old_table->space_id and old_table->space->chain.start->name are used in row_make_new_pathname but only old_table->space_id is checked. Discarded tables seem to have non-zero space_id and NULL space. Are we missing a NULL check here?
            shihche Shihao Chen added a comment -

            Similarly, in fil_mtr_rename_log@fil0fil.cc:

            if (old_table->space_id) {
                    /* omitting unrelated code */
            	const char* old_path = old_table->space->chain.start->name;
            

            member of space struct is accessed without a null check against old_table->space.

            shihche Shihao Chen added a comment - Similarly, in fil_mtr_rename_log@fil0fil.cc: if (old_table->space_id) { /* omitting unrelated code */ const char* old_path = old_table->space->chain.start->name; member of space struct is accessed without a null check against old_table->space.
            shihche Shihao Chen added a comment -

            Would like to make the change that aligns the behaviour of 10.3 and after with that of 10.2. Do I create a PR tagging this MDEV directly or is there any pre-work to do?

            shihche Shihao Chen added a comment - Would like to make the change that aligns the behaviour of 10.3 and after with that of 10.2. Do I create a PR tagging this MDEV directly or is there any pre-work to do?
            shihche Shihao Chen added a comment - - edited

            On a closer look the fix might take more work than I imagined.
            In commit_try_rebuild@handler0alter.cc:

            /* The new table must inherit the flag from the
            "parent" table. */
            if (!user_table->space) {
            	rebuilt_table->file_unreadable = true;
            	rebuilt_table->flags2 |= DICT_TF2_DISCARDED;
            }
            

            So when executing "alter table t engine innodb" on a discarded table, the new table will be created with discarded and unreadable flag but with a tablespace.
            Consequently in dict_table_rename_in_cache@dict0dict.cc:

            if (!table->space) {
                // deleting the tablespace
            }else{
                // renaming the tablespace    
            }
            

            As the newly altered table has a tablespace(despite flagged as discarded), it will rename its .ibd into t.ibd, which confuses the server on subsequent queries.
            Is it expected behaviour to create a tablespace when inplace altering a discarded table? <- I guess I can work out a fix by checking discarded flag along with tablespace existence, just curious if there's any further reason we create a discarded tablespace in the first place.

            shihche Shihao Chen added a comment - - edited On a closer look the fix might take more work than I imagined. In commit_try_rebuild@handler0alter.cc: /* The new table must inherit the flag from the "parent" table. */ if (!user_table->space) { rebuilt_table->file_unreadable = true; rebuilt_table->flags2 |= DICT_TF2_DISCARDED; } So when executing "alter table t engine innodb" on a discarded table, the new table will be created with discarded and unreadable flag but with a tablespace . Consequently in dict_table_rename_in_cache@dict0dict.cc: if (!table->space) { // deleting the tablespace }else{ // renaming the tablespace } As the newly altered table has a tablespace(despite flagged as discarded), it will rename its .ibd into t.ibd, which confuses the server on subsequent queries. Is it expected behaviour to create a tablespace when inplace altering a discarded table? <- I guess I can work out a fix by checking discarded flag along with tablespace existence, just curious if there's any further reason we create a discarded tablespace in the first place.
            alice Alice Sherepa added a comment -

            The crash happens on 10.3, 10.4, but not on 10.5

            10.3 b633b6a9d8278a3e0d9baaf83

            #4  row_make_new_pathname (table=0x7f3c4808dc90, new_name=0x7f3c480a8c88 "test/#sql-ib22") at /d1/git/10.3/storage/innobase/row/row0merge.cc:4286
            #5  0x000055796e090a00 in row_merge_rename_tables_dict (old_table=0x7f3c4808dc90, new_table=0x7f3c480baf60, tmp_name=0x7f3c480a8c88 "test/#sql-ib22", trx=0x7f3c9bc011c8) at /d1/git/10.3/storage/innobase/row/row0merge.cc:4341
            #6  0x000055796df63a58 in commit_try_rebuild (ha_alter_info=0x7f3c9b29f190, ctx=0x7f3c48013cf8, altered_table=0x7f3c480b9ec0, old_table=0x7f3c48036390, trx=0x7f3c9bc011c8, table_name=0x7f3c4808da25 "t") at /d1/git/10.3/storage/innobase/handler/handler0alter.cc:8602
            #7  0x000055796df5c05e in ha_innobase::commit_inplace_alter_table (this=0x7f3c480a73d8, altered_table=0x7f3c480b9ec0, ha_alter_info=0x7f3c9b29f190, commit=true) at /d1/git/10.3/storage/innobase/handler/handler0alter.cc:9567
            #8  0x000055796dce7fd8 in handler::ha_commit_inplace_alter_table (this=0x7f3c480a73d8, altered_table=0x7f3c480b9ec0, ha_alter_info=0x7f3c9b29f190, commit=true) at /d1/git/10.3/sql/handler.cc:4596
            #9  0x000055796daa6aad in mysql_inplace_alter_table (thd=0x7f3c48000d50, table_list=0x7f3c48012b60, table=0x7f3c48036390, altered_table=0x7f3c480b9ec0, ha_alter_info=0x7f3c9b29f190, inplace_supported=HA_ALTER_INPLACE_COPY_NO_LOCK, target_mdl_request=0x7f3c9b29f310, alter_ctx=0x7f3c9b29f8c0) at /d1/git/10.3/sql/sql_table.cc:7701
            #10 0x000055796daad251 in mysql_alter_table (thd=0x7f3c48000d50, new_db=0x7f3c48005438, new_name=0x7f3c480057f8, create_info=0x7f3c9b2a04b0, table_list=0x7f3c48012b60, alter_info=0x7f3c9b2a03f0, order_num=0, order=0x0, ignore=false) at /d1/git/10.3/sql/sql_table.cc:9941
            #11 0x000055796db3b0b4 in Sql_cmd_alter_table::execute (this=0x7f3c480131c8, thd=0x7f3c48000d50) at /d1/git/10.3/sql/sql_alter.cc:512
            #12 0x000055796d9cce7b in mysql_execute_command (thd=0x7f3c48000d50) at /d1/git/10.3/sql/sql_parse.cc:6030
            #13 0x000055796d9d25e6 in mysql_parse (thd=0x7f3c48000d50, rawbuf=0x7f3c48012a78 "ALTER TABLE t ENGINE INNODB", length=27, parser_state=0x7f3c9b2a15c0, is_com_multi=false, is_next_command=false) at /d1/git/10.3/sql/sql_parse.cc:7818
            #14 0x000055796d9bef29 in dispatch_command (command=COM_QUERY, thd=0x7f3c48000d50, packet=0x7f3c48008ed1 "ALTER TABLE t ENGINE INNODB", packet_length=27, is_com_multi=false, is_next_command=false) at /d1/git/10.3/sql/sql_parse.cc:1855
            #15 0x000055796d9bd84c in do_command (thd=0x7f3c48000d50) at /d1/git/10.3/sql/sql_parse.cc:1401
            #16 0x000055796db35168 in do_handle_one_connection (connect=0x557970fa7fb0) at /d1/git/10.3/sql/sql_connect.cc:1403
            #17 0x000055796db34eca in handle_one_connection (arg=0x557970fa7fb0) at /d1/git/10.3/sql/sql_connect.cc:1308
            #18 0x000055796e4cfd21 in pfs_spawn_thread (arg=0x5579712277e0) at /d1/git/10.3/storage/perfschema/pfs.cc:1869
            #19 0x00007f3ca6880fa3 in start_thread (arg=<optimized out>) at pthread_create.c:486
            #20 0x00007f3ca62044cf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
            

            10.5 605555fc31784302a54d39

            MariaDB [test]> CREATE TABLE t (a INT) ENGINE=INNODB;
            Query OK, 0 rows affected (0.017 sec)
             
            MariaDB [test]> ALTER TABLE t DISCARD TABLESPACE;
            Query OK, 0 rows affected (0.007 sec)
             
            MariaDB [test]> ALTER TABLE t ENGINE INNODB;
            ERROR 1296 (HY000): Got error 192 '' from InnoDB
            Warning (Code 1814): Tablespace has been discarded for table `t`
            Warning (Code 192): Table t in file ./test/t.ibd is encrypted but encryption service or used key_id is not available.  Can't continue reading table.
            Error (Code 1296): Got error 192 '' from InnoDB
            

            alice Alice Sherepa added a comment - The crash happens on 10.3, 10.4, but not on 10.5 10.3 b633b6a9d8278a3e0d9baaf83 #4 row_make_new_pathname (table=0x7f3c4808dc90, new_name=0x7f3c480a8c88 "test/#sql-ib22") at /d1/git/10.3/storage/innobase/row/row0merge.cc:4286 #5 0x000055796e090a00 in row_merge_rename_tables_dict (old_table=0x7f3c4808dc90, new_table=0x7f3c480baf60, tmp_name=0x7f3c480a8c88 "test/#sql-ib22", trx=0x7f3c9bc011c8) at /d1/git/10.3/storage/innobase/row/row0merge.cc:4341 #6 0x000055796df63a58 in commit_try_rebuild (ha_alter_info=0x7f3c9b29f190, ctx=0x7f3c48013cf8, altered_table=0x7f3c480b9ec0, old_table=0x7f3c48036390, trx=0x7f3c9bc011c8, table_name=0x7f3c4808da25 "t") at /d1/git/10.3/storage/innobase/handler/handler0alter.cc:8602 #7 0x000055796df5c05e in ha_innobase::commit_inplace_alter_table (this=0x7f3c480a73d8, altered_table=0x7f3c480b9ec0, ha_alter_info=0x7f3c9b29f190, commit=true) at /d1/git/10.3/storage/innobase/handler/handler0alter.cc:9567 #8 0x000055796dce7fd8 in handler::ha_commit_inplace_alter_table (this=0x7f3c480a73d8, altered_table=0x7f3c480b9ec0, ha_alter_info=0x7f3c9b29f190, commit=true) at /d1/git/10.3/sql/handler.cc:4596 #9 0x000055796daa6aad in mysql_inplace_alter_table (thd=0x7f3c48000d50, table_list=0x7f3c48012b60, table=0x7f3c48036390, altered_table=0x7f3c480b9ec0, ha_alter_info=0x7f3c9b29f190, inplace_supported=HA_ALTER_INPLACE_COPY_NO_LOCK, target_mdl_request=0x7f3c9b29f310, alter_ctx=0x7f3c9b29f8c0) at /d1/git/10.3/sql/sql_table.cc:7701 #10 0x000055796daad251 in mysql_alter_table (thd=0x7f3c48000d50, new_db=0x7f3c48005438, new_name=0x7f3c480057f8, create_info=0x7f3c9b2a04b0, table_list=0x7f3c48012b60, alter_info=0x7f3c9b2a03f0, order_num=0, order=0x0, ignore=false) at /d1/git/10.3/sql/sql_table.cc:9941 #11 0x000055796db3b0b4 in Sql_cmd_alter_table::execute (this=0x7f3c480131c8, thd=0x7f3c48000d50) at /d1/git/10.3/sql/sql_alter.cc:512 #12 0x000055796d9cce7b in mysql_execute_command (thd=0x7f3c48000d50) at /d1/git/10.3/sql/sql_parse.cc:6030 #13 0x000055796d9d25e6 in mysql_parse (thd=0x7f3c48000d50, rawbuf=0x7f3c48012a78 "ALTER TABLE t ENGINE INNODB", length=27, parser_state=0x7f3c9b2a15c0, is_com_multi=false, is_next_command=false) at /d1/git/10.3/sql/sql_parse.cc:7818 #14 0x000055796d9bef29 in dispatch_command (command=COM_QUERY, thd=0x7f3c48000d50, packet=0x7f3c48008ed1 "ALTER TABLE t ENGINE INNODB", packet_length=27, is_com_multi=false, is_next_command=false) at /d1/git/10.3/sql/sql_parse.cc:1855 #15 0x000055796d9bd84c in do_command (thd=0x7f3c48000d50) at /d1/git/10.3/sql/sql_parse.cc:1401 #16 0x000055796db35168 in do_handle_one_connection (connect=0x557970fa7fb0) at /d1/git/10.3/sql/sql_connect.cc:1403 #17 0x000055796db34eca in handle_one_connection (arg=0x557970fa7fb0) at /d1/git/10.3/sql/sql_connect.cc:1308 #18 0x000055796e4cfd21 in pfs_spawn_thread (arg=0x5579712277e0) at /d1/git/10.3/storage/perfschema/pfs.cc:1869 #19 0x00007f3ca6880fa3 in start_thread (arg=<optimized out>) at pthread_create.c:486 #20 0x00007f3ca62044cf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 10.5 605555fc31784302a54d39 MariaDB [test]> CREATE TABLE t (a INT) ENGINE=INNODB; Query OK, 0 rows affected (0.017 sec)   MariaDB [test]> ALTER TABLE t DISCARD TABLESPACE; Query OK, 0 rows affected (0.007 sec)   MariaDB [test]> ALTER TABLE t ENGINE INNODB; ERROR 1296 (HY000): Got error 192 '' from InnoDB Warning (Code 1814): Tablespace has been discarded for table `t` Warning (Code 192): Table t in file ./test/t.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table. Error (Code 1296): Got error 192 '' from InnoDB
            Roel Roel Van de Paar added a comment - - edited

            USE test;
            CREATE TABLE t(c INT) ENGINE=InnoDB;
            ALTER TABLE t DISCARD TABLESPACE;
            OPTIMIZE TABLE t;
            

            Leads to:

            10.4.15 eae968f62d285de97ed607c87bc131cd863d5d03 (Debug)

            Core was generated by `/test/MD110820-mariadb-10.4.15-linux-x86_64-dbg/bin/mysqld --no-defaults --core'.
            Program terminated with signal SIGSEGV, Segmentation fault.
            #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11)
                at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
            [Current thread is 1 (Thread 0x14fc06360700 (LWP 583872))]
            (gdb) bt
            #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
            #1  0x00005623bd6238a6 in my_write_core (sig=sig@entry=11) at /test/10.4_dbg/mysys/stacktrace.c:482
            #2  0x00005623bcd9fcdc in handle_fatal_signal (sig=11) at /test/10.4_dbg/sql/signal_handler.cc:343
            #3  <signal handler called>
            #4  0x00005623bd137fe2 in row_make_new_pathname (table=table@entry=0x14fbdec9a480, new_name=new_name@entry=0x14fbdec42ce8 "test/#sql-ib22") at /test/10.4_dbg/storage/innobase/row/row0merge.cc:4280
            #5  0x00005623bd13cc12 in row_merge_rename_tables_dict (old_table=old_table@entry=0x14fbdec9a480, new_table=new_table@entry=0x14fbdec9a880, tmp_name=0x14fbdec42ce8 "test/#sql-ib22", trx=trx@entry=0x14fbf0c03380) at /test/10.4_dbg/storage/innobase/row/row0merge.cc:4335
            #6  0x00005623bd0171b0 in commit_try_rebuild (ha_alter_info=ha_alter_info@entry=0x14fc0635a190, ctx=ctx@entry=0x14fbdec6e630, altered_table=altered_table@entry=0x14fc0635a230, old_table=<optimized out>, trx=<optimized out>, table_name=<optimized out>) at /test/10.4_dbg/storage/innobase/handler/handler0alter.cc:9944
            #7  0x00005623bd00c462 in ha_innobase::commit_inplace_alter_table (this=0x14fbdec7a088, altered_table=0x14fc0635a230, ha_alter_info=0x14fc0635a190, commit=true) at /test/10.4_dbg/storage/innobase/handler/handler0alter.cc:11016
            #8  0x00005623bcdadd63 in handler::ha_commit_inplace_alter_table (this=0x14fbdec7a088, altered_table=altered_table@entry=0x14fc0635a230, ha_alter_info=ha_alter_info@entry=0x14fc0635a190, commit=commit@entry=true) at /test/10.4_dbg/sql/handler.cc:4616
            #9  0x00005623bcba889f in mysql_inplace_alter_table (thd=thd@entry=0x14fbdec15070, table_list=0x14fbdec6d148, table=table@entry=0x14fbdecfd070, altered_table=altered_table@entry=0x14fc0635a230, ha_alter_info=ha_alter_info@entry=0x14fc0635a190, target_mdl_request=target_mdl_request@entry=0x14fc0635b180, alter_ctx=0x14fc0635bcc0) at /test/10.4_dbg/sql/sql_table.cc:7797
            #10 0x00005623bcbb5c9f in mysql_alter_table (thd=thd@entry=0x14fbdec15070, new_db=<optimized out>, new_name=<optimized out>, create_info=create_info@entry=0x14fc0635c880, table_list=<optimized out>, table_list@entry=0x14fbdec6d148, alter_info=alter_info@entry=0x14fc0635c7c0, order_num=0, order=0x0, ignore=false) at /test/10.4_dbg/sql/sql_table.cc:10156
            #11 0x00005623bcbb7967 in mysql_recreate_table (thd=thd@entry=0x14fbdec15070, table_list=table_list@entry=0x14fbdec6d148, table_copy=table_copy@entry=false) at /test/10.4_dbg/sql/sql_table.cc:11001
            #12 0x00005623bcc387f6 in admin_recreate_table (thd=thd@entry=0x14fbdec15070, table_list=table_list@entry=0x14fbdec6d148) at /test/10.4_dbg/sql/sql_admin.cc:59
            #13 0x00005623bcc3b3f8 in mysql_admin_table (thd=thd@entry=0x14fbdec15070, tables=tables@entry=0x14fbdec6d148, check_opt=check_opt@entry=0x14fbdec1a248, operator_name=operator_name@entry=0x5623bd72a19e "optimize", lock_type=lock_type@entry=TL_WRITE, org_open_for_modify=org_open_for_modify@entry=true, repair_table_use_frm=false, extra_open_options=0, prepare_func=0x0, operator_func=(int (handler::*)(handler * const, THD *, HA_CHECK_OPT *)) 0x5623bcdad856 <handler::ha_optimize(THD*, st_ha_check_opt*)>, view_operator_func=0x0) at /test/10.4_dbg/sql/sql_admin.cc:1036
            #14 0x00005623bcc3c1ed in Sql_cmd_optimize_table::execute (this=<optimized out>, thd=0x14fbdec15070) at /test/10.4_dbg/sql/sql_admin.cc:1380
            #15 0x00005623bcaf4a3d in mysql_execute_command (thd=thd@entry=0x14fbdec15070) at /test/10.4_dbg/sql/sql_parse.cc:6098
            #16 0x00005623bcaf7090 in mysql_parse (thd=thd@entry=0x14fbdec15070, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14fc0635f460, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.4_dbg/sql/sql_parse.cc:7896
            #17 0x00005623bcaf9920 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14fbdec15070, packet=packet@entry=0x14fbdec57071 "", packet_length=packet_length@entry=16, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.4_dbg/sql/sql_parse.cc:1834
            #18 0x00005623bcafd35b in do_command (thd=0x14fbdec15070) at /test/10.4_dbg/sql/sql_parse.cc:1352
            #19 0x00005623bcc298b6 in do_handle_one_connection (connect=connect@entry=0x14fc03035790) at /test/10.4_dbg/sql/sql_connect.cc:1412
            #20 0x00005623bcc299d6 in handle_one_connection (arg=0x14fc03035790) at /test/10.4_dbg/sql/sql_connect.cc:1316
            #21 0x000014fc0555e6db in start_thread (arg=0x14fc06360700) at pthread_create.c:463
            #22 0x000014fc046d8a3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
            

            10.4.15 eae968f62d285de97ed607c87bc131cd863d5d03 (Optimized)

            Core was generated by `/test/MD110820-mariadb-10.4.15-linux-x86_64-opt/bin/mysqld --no-defaults --core'.
            Program terminated with signal SIGSEGV, Segmentation fault.
            #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11)
                at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
            [Current thread is 1 (Thread 0x1511c881e700 (LWP 594389))]
            (gdb) bt
            #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
            #1  0x0000562391ceba77 in my_write_core (sig=sig@entry=11) at /test/10.4_opt/mysys/stacktrace.c:482
            #2  0x00005623916c362a in handle_fatal_signal (sig=11) at /test/10.4_opt/sql/signal_handler.cc:343
            #3  <signal handler called>
            #4  row_make_new_pathname (new_name=0x1511a14217c0 "test/#sql-ib22", table=0x1511a14842e8) at /test/10.4_opt/storage/innobase/row/row0merge.cc:4280
            #5  row_merge_rename_tables_dict (old_table=old_table@entry=0x1511a14842e8, new_table=new_table@entry=0x1511a1484668, tmp_name=0x1511a14217c0 "test/#sql-ib22", trx=trx@entry=0x1511b30031e8) at /test/10.4_opt/storage/innobase/row/row0merge.cc:4335
            #6  0x000056239188584f in commit_try_rebuild (table_name=<optimized out>, trx=<optimized out>, old_table=<optimized out>, altered_table=<optimized out>, ctx=0x1511a14405a8, ha_alter_info=<optimized out>) at /test/10.4_opt/storage/innobase/handler/handler0alter.cc:9944
            #7  ha_innobase::commit_inplace_alter_table (this=0x1511a1464020, altered_table=<optimized out>, ha_alter_info=<optimized out>, commit=<optimized out>) at /test/10.4_opt/storage/innobase/handler/handler0alter.cc:11016
            #8  0x0000562391549ad2 in mysql_inplace_alter_table (target_mdl_request=0x1511c8818ff0, alter_ctx=0x1511c881a100, ha_alter_info=0x1511c88180c0, altered_table=0x1511c8818160, table=0x1511a14cee08, table_list=0x1511a143f0e0, thd=0x1511a1412008) at /test/10.4_opt/sql/sql_table.cc:7797
            #9  mysql_alter_table (thd=thd@entry=0x1511a1412008, new_db=<optimized out>, new_name=<optimized out>, create_info=create_info@entry=0x1511c881acb0, table_list=<optimized out>, table_list@entry=0x1511a143f0e0, alter_info=<optimized out>, order_num=0, order=0x0, ignore=false) at /test/10.4_opt/sql/sql_table.cc:10156
            #10 0x000056239154aae8 in mysql_recreate_table (thd=thd@entry=0x1511a1412008, table_list=table_list@entry=0x1511a143f0e0, table_copy=table_copy@entry=false) at /test/10.4_opt/sql/sql_table.cc:11001
            #11 0x00005623915a5c6d in admin_recreate_table (thd=thd@entry=0x1511a1412008, table_list=table_list@entry=0x1511a143f0e0) at /test/10.4_opt/sql/sql_admin.cc:59
            #12 0x00005623915a7154 in mysql_admin_table (thd=thd@entry=0x1511a1412008, tables=tables@entry=0x1511a143f0e0, check_opt=check_opt@entry=0x1511a1417020, operator_name=operator_name@entry=0x562391f0a056 "optimize", lock_type=lock_type@entry=TL_WRITE, org_open_for_modify=org_open_for_modify@entry=true, repair_table_use_frm=false, extra_open_options=0, prepare_func=0x0, operator_func=<optimized out>, view_operator_func=0x0) at /test/10.4_opt/sql/sql_admin.cc:1036
            #13 0x00005623915a8480 in Sql_cmd_optimize_table::execute (this=<optimized out>, thd=0x1511a1412008) at /test/10.4_opt/sql/sql_admin.cc:1380
            #14 0x00005623914b2ca4 in mysql_execute_command (thd=thd@entry=0x1511a1412008) at /test/10.4_opt/sql/sql_parse.cc:6098
            #15 0x00005623914ba22a in mysql_parse (thd=0x1511a1412008, rawbuf=<optimized out>, length=16, parser_state=0x1511c881d4d0, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /test/10.4_opt/sql/sql_parse.cc:7896
            #16 0x00005623914bc685 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x1511a1412008, packet=packet@entry=0x1511a1432009 "", packet_length=packet_length@entry=16, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.4_opt/sql/sql_parse.cc:1834
            #17 0x00005623914bde04 in do_command (thd=0x1511a1412008) at /test/10.4_opt/sql/sql_parse.cc:1352
            #18 0x000056239159adbe in do_handle_one_connection (connect=connect@entry=0x1511c5432748) at /test/10.4_opt/sql/sql_connect.cc:1412
            #19 0x000056239159ae7d in handle_one_connection (arg=0x1511c5432748) at /test/10.4_opt/sql/sql_connect.cc:1316
            #20 0x00001511c7a1c6db in start_thread (arg=0x1511c881e700) at pthread_create.c:463
            #21 0x00001511c6b96a3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
            

            Bug confirmed present in:
            MariaDB: 10.3.25 (dbg), 10.3.25 (opt), 10.4.15 (dbg), 10.4.15 (opt)

            Bug confirmed not present in:
            MariaDB: 10.1.47 (dbg), 10.1.47 (opt), 10.2.34 (dbg), 10.2.34 (opt), 10.5.6 (dbg), 10.5.6 (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)

            Roel Roel Van de Paar added a comment - - edited USE test; CREATE TABLE t(c INT) ENGINE=InnoDB; ALTER TABLE t DISCARD TABLESPACE; OPTIMIZE TABLE t; Leads to: 10.4.15 eae968f62d285de97ed607c87bc131cd863d5d03 (Debug) Core was generated by `/test/MD110820-mariadb-10.4.15-linux-x86_64-dbg/bin/mysqld --no-defaults --core'. Program terminated with signal SIGSEGV, Segmentation fault. #0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57 [Current thread is 1 (Thread 0x14fc06360700 (LWP 583872))] (gdb) bt #0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57 #1 0x00005623bd6238a6 in my_write_core (sig=sig@entry=11) at /test/10.4_dbg/mysys/stacktrace.c:482 #2 0x00005623bcd9fcdc in handle_fatal_signal (sig=11) at /test/10.4_dbg/sql/signal_handler.cc:343 #3 <signal handler called> #4 0x00005623bd137fe2 in row_make_new_pathname (table=table@entry=0x14fbdec9a480, new_name=new_name@entry=0x14fbdec42ce8 "test/#sql-ib22") at /test/10.4_dbg/storage/innobase/row/row0merge.cc:4280 #5 0x00005623bd13cc12 in row_merge_rename_tables_dict (old_table=old_table@entry=0x14fbdec9a480, new_table=new_table@entry=0x14fbdec9a880, tmp_name=0x14fbdec42ce8 "test/#sql-ib22", trx=trx@entry=0x14fbf0c03380) at /test/10.4_dbg/storage/innobase/row/row0merge.cc:4335 #6 0x00005623bd0171b0 in commit_try_rebuild (ha_alter_info=ha_alter_info@entry=0x14fc0635a190, ctx=ctx@entry=0x14fbdec6e630, altered_table=altered_table@entry=0x14fc0635a230, old_table=<optimized out>, trx=<optimized out>, table_name=<optimized out>) at /test/10.4_dbg/storage/innobase/handler/handler0alter.cc:9944 #7 0x00005623bd00c462 in ha_innobase::commit_inplace_alter_table (this=0x14fbdec7a088, altered_table=0x14fc0635a230, ha_alter_info=0x14fc0635a190, commit=true) at /test/10.4_dbg/storage/innobase/handler/handler0alter.cc:11016 #8 0x00005623bcdadd63 in handler::ha_commit_inplace_alter_table (this=0x14fbdec7a088, altered_table=altered_table@entry=0x14fc0635a230, ha_alter_info=ha_alter_info@entry=0x14fc0635a190, commit=commit@entry=true) at /test/10.4_dbg/sql/handler.cc:4616 #9 0x00005623bcba889f in mysql_inplace_alter_table (thd=thd@entry=0x14fbdec15070, table_list=0x14fbdec6d148, table=table@entry=0x14fbdecfd070, altered_table=altered_table@entry=0x14fc0635a230, ha_alter_info=ha_alter_info@entry=0x14fc0635a190, target_mdl_request=target_mdl_request@entry=0x14fc0635b180, alter_ctx=0x14fc0635bcc0) at /test/10.4_dbg/sql/sql_table.cc:7797 #10 0x00005623bcbb5c9f in mysql_alter_table (thd=thd@entry=0x14fbdec15070, new_db=<optimized out>, new_name=<optimized out>, create_info=create_info@entry=0x14fc0635c880, table_list=<optimized out>, table_list@entry=0x14fbdec6d148, alter_info=alter_info@entry=0x14fc0635c7c0, order_num=0, order=0x0, ignore=false) at /test/10.4_dbg/sql/sql_table.cc:10156 #11 0x00005623bcbb7967 in mysql_recreate_table (thd=thd@entry=0x14fbdec15070, table_list=table_list@entry=0x14fbdec6d148, table_copy=table_copy@entry=false) at /test/10.4_dbg/sql/sql_table.cc:11001 #12 0x00005623bcc387f6 in admin_recreate_table (thd=thd@entry=0x14fbdec15070, table_list=table_list@entry=0x14fbdec6d148) at /test/10.4_dbg/sql/sql_admin.cc:59 #13 0x00005623bcc3b3f8 in mysql_admin_table (thd=thd@entry=0x14fbdec15070, tables=tables@entry=0x14fbdec6d148, check_opt=check_opt@entry=0x14fbdec1a248, operator_name=operator_name@entry=0x5623bd72a19e "optimize", lock_type=lock_type@entry=TL_WRITE, org_open_for_modify=org_open_for_modify@entry=true, repair_table_use_frm=false, extra_open_options=0, prepare_func=0x0, operator_func=(int (handler::*)(handler * const, THD *, HA_CHECK_OPT *)) 0x5623bcdad856 <handler::ha_optimize(THD*, st_ha_check_opt*)>, view_operator_func=0x0) at /test/10.4_dbg/sql/sql_admin.cc:1036 #14 0x00005623bcc3c1ed in Sql_cmd_optimize_table::execute (this=<optimized out>, thd=0x14fbdec15070) at /test/10.4_dbg/sql/sql_admin.cc:1380 #15 0x00005623bcaf4a3d in mysql_execute_command (thd=thd@entry=0x14fbdec15070) at /test/10.4_dbg/sql/sql_parse.cc:6098 #16 0x00005623bcaf7090 in mysql_parse (thd=thd@entry=0x14fbdec15070, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14fc0635f460, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.4_dbg/sql/sql_parse.cc:7896 #17 0x00005623bcaf9920 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14fbdec15070, packet=packet@entry=0x14fbdec57071 "", packet_length=packet_length@entry=16, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.4_dbg/sql/sql_parse.cc:1834 #18 0x00005623bcafd35b in do_command (thd=0x14fbdec15070) at /test/10.4_dbg/sql/sql_parse.cc:1352 #19 0x00005623bcc298b6 in do_handle_one_connection (connect=connect@entry=0x14fc03035790) at /test/10.4_dbg/sql/sql_connect.cc:1412 #20 0x00005623bcc299d6 in handle_one_connection (arg=0x14fc03035790) at /test/10.4_dbg/sql/sql_connect.cc:1316 #21 0x000014fc0555e6db in start_thread (arg=0x14fc06360700) at pthread_create.c:463 #22 0x000014fc046d8a3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 10.4.15 eae968f62d285de97ed607c87bc131cd863d5d03 (Optimized) Core was generated by `/test/MD110820-mariadb-10.4.15-linux-x86_64-opt/bin/mysqld --no-defaults --core'. Program terminated with signal SIGSEGV, Segmentation fault. #0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57 [Current thread is 1 (Thread 0x1511c881e700 (LWP 594389))] (gdb) bt #0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57 #1 0x0000562391ceba77 in my_write_core (sig=sig@entry=11) at /test/10.4_opt/mysys/stacktrace.c:482 #2 0x00005623916c362a in handle_fatal_signal (sig=11) at /test/10.4_opt/sql/signal_handler.cc:343 #3 <signal handler called> #4 row_make_new_pathname (new_name=0x1511a14217c0 "test/#sql-ib22", table=0x1511a14842e8) at /test/10.4_opt/storage/innobase/row/row0merge.cc:4280 #5 row_merge_rename_tables_dict (old_table=old_table@entry=0x1511a14842e8, new_table=new_table@entry=0x1511a1484668, tmp_name=0x1511a14217c0 "test/#sql-ib22", trx=trx@entry=0x1511b30031e8) at /test/10.4_opt/storage/innobase/row/row0merge.cc:4335 #6 0x000056239188584f in commit_try_rebuild (table_name=<optimized out>, trx=<optimized out>, old_table=<optimized out>, altered_table=<optimized out>, ctx=0x1511a14405a8, ha_alter_info=<optimized out>) at /test/10.4_opt/storage/innobase/handler/handler0alter.cc:9944 #7 ha_innobase::commit_inplace_alter_table (this=0x1511a1464020, altered_table=<optimized out>, ha_alter_info=<optimized out>, commit=<optimized out>) at /test/10.4_opt/storage/innobase/handler/handler0alter.cc:11016 #8 0x0000562391549ad2 in mysql_inplace_alter_table (target_mdl_request=0x1511c8818ff0, alter_ctx=0x1511c881a100, ha_alter_info=0x1511c88180c0, altered_table=0x1511c8818160, table=0x1511a14cee08, table_list=0x1511a143f0e0, thd=0x1511a1412008) at /test/10.4_opt/sql/sql_table.cc:7797 #9 mysql_alter_table (thd=thd@entry=0x1511a1412008, new_db=<optimized out>, new_name=<optimized out>, create_info=create_info@entry=0x1511c881acb0, table_list=<optimized out>, table_list@entry=0x1511a143f0e0, alter_info=<optimized out>, order_num=0, order=0x0, ignore=false) at /test/10.4_opt/sql/sql_table.cc:10156 #10 0x000056239154aae8 in mysql_recreate_table (thd=thd@entry=0x1511a1412008, table_list=table_list@entry=0x1511a143f0e0, table_copy=table_copy@entry=false) at /test/10.4_opt/sql/sql_table.cc:11001 #11 0x00005623915a5c6d in admin_recreate_table (thd=thd@entry=0x1511a1412008, table_list=table_list@entry=0x1511a143f0e0) at /test/10.4_opt/sql/sql_admin.cc:59 #12 0x00005623915a7154 in mysql_admin_table (thd=thd@entry=0x1511a1412008, tables=tables@entry=0x1511a143f0e0, check_opt=check_opt@entry=0x1511a1417020, operator_name=operator_name@entry=0x562391f0a056 "optimize", lock_type=lock_type@entry=TL_WRITE, org_open_for_modify=org_open_for_modify@entry=true, repair_table_use_frm=false, extra_open_options=0, prepare_func=0x0, operator_func=<optimized out>, view_operator_func=0x0) at /test/10.4_opt/sql/sql_admin.cc:1036 #13 0x00005623915a8480 in Sql_cmd_optimize_table::execute (this=<optimized out>, thd=0x1511a1412008) at /test/10.4_opt/sql/sql_admin.cc:1380 #14 0x00005623914b2ca4 in mysql_execute_command (thd=thd@entry=0x1511a1412008) at /test/10.4_opt/sql/sql_parse.cc:6098 #15 0x00005623914ba22a in mysql_parse (thd=0x1511a1412008, rawbuf=<optimized out>, length=16, parser_state=0x1511c881d4d0, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /test/10.4_opt/sql/sql_parse.cc:7896 #16 0x00005623914bc685 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x1511a1412008, packet=packet@entry=0x1511a1432009 "", packet_length=packet_length@entry=16, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.4_opt/sql/sql_parse.cc:1834 #17 0x00005623914bde04 in do_command (thd=0x1511a1412008) at /test/10.4_opt/sql/sql_parse.cc:1352 #18 0x000056239159adbe in do_handle_one_connection (connect=connect@entry=0x1511c5432748) at /test/10.4_opt/sql/sql_connect.cc:1412 #19 0x000056239159ae7d in handle_one_connection (arg=0x1511c5432748) at /test/10.4_opt/sql/sql_connect.cc:1316 #20 0x00001511c7a1c6db in start_thread (arg=0x1511c881e700) at pthread_create.c:463 #21 0x00001511c6b96a3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Bug confirmed present in: MariaDB: 10.3.25 (dbg), 10.3.25 (opt), 10.4.15 (dbg), 10.4.15 (opt) Bug confirmed not present in: MariaDB: 10.1.47 (dbg), 10.1.47 (opt), 10.2.34 (dbg), 10.2.34 (opt), 10.5.6 (dbg), 10.5.6 (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)

            Even though I was not able to repeat a failure in 10.2, I applied the fix also there. The test innodb.alter_missing_tablespace covers the case where an AUTO_INCREMENT value of an existing table is changed without rebuilding the table. To fix this bug, a similar check had to be added to the table-rebuilding case. Other forms of native ALTER TABLE are deliberately allowed even though the tablespace is missing, to retain compatibility with MySQL 5.7.

            marko Marko Mäkelä added a comment - Even though I was not able to repeat a failure in 10.2, I applied the fix also there. The test innodb.alter_missing_tablespace covers the case where an AUTO_INCREMENT value of an existing table is changed without rebuilding the table. To fix this bug, a similar check had to be added to the table-rebuilding case. Other forms of native ALTER TABLE are deliberately allowed even though the tablespace is missing, to retain compatibility with MySQL 5.7.

            People

              marko Marko Mäkelä
              shihche Shihao Chen
              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.