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

InnoDB aborts while adding instant column for discarded tablespace | SIGSEGV in mtr_t::set_named_space (on optimized builds)

Details

    Description

      USE test;
      CREATE TABLE t(a INT);
      ALTER TABLE t DISCARD TABLESPACE;
      ALTER TABLE t ADD COLUMN c INT;
      

      Leads to:

      10.5.3 f544a712c8a2ef3f3ecba80cb2782b1839fb36ab

      Core was generated by `/test/MD010520-mariadb-10.5.3-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 0x7f9b9e076700 (LWP 3236870))]
      (gdb) bt
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
      #1  0x0000561de0b7dac7 in my_write_core (sig=sig@entry=11) at /test/10.5_opt/mysys/stacktrace.c:518
      #2  0x0000561de053f7ca in handle_fatal_signal (sig=11) at /test/10.5_opt/sql/signal_handler.cc:329
      #3  <signal handler called>
      #4  mtr_t::set_named_space (this=0x7f9b9e070870, space=0x0) at /test/10.5_opt/storage/innobase/include/mtr0mtr.h:206
      #5  dict_index_t::set_modified (mtr=..., this=0x7f9b6d4d5680) at /test/10.5_opt/storage/innobase/include/dict0mem.h:2286
      #6  innobase_instant_try (ha_alter_info=ha_alter_info@entry=0x7f9b9e0716b0, ctx=ctx@entry=0x7f9b6d4486f0, trx=trx@entry=0x7f9b88403200, table=<optimized out>, altered_table=<optimized out>, altered_table=<optimized out>) at /test/10.5_opt/storage/innobase/handler/handler0alter.cc:5797
      #7  0x0000561de088694b in commit_try_norebuild (ha_alter_info=0x7f9b9e0716b0, ctx=<optimized out>, altered_table=0x7f9b9e071750, old_table=0x7f9b6d4dee18, trx=<optimized out>, table_name=<optimized out>) at /test/10.5_opt/storage/innobase/handler/handler0alter.cc:10170
      #8  0x0000561de087d7dd in ha_innobase::commit_inplace_alter_table (this=<optimized out>, altered_table=<optimized out>, ha_alter_info=<optimized out>, commit=<optimized out>) at /test/10.5_opt/storage/innobase/handler/handler0alter.cc:10890
      #9  0x0000561de03e2d29 in mysql_inplace_alter_table (target_mdl_request=0x7f9b9e072510, alter_ctx=0x7f9b9e073a40, inplace_supported=<optimized out>, ha_alter_info=0x7f9b9e0716b0, altered_table=0x7f9b9e071750, table=<optimized out>, table_list=0x7f9b6d447118, thd=0x7f9b6d412018) at /test/10.5_opt/sql/sql_table.cc:7925
      #10 mysql_alter_table (thd=thd@entry=0x7f9b6d412018, new_db=new_db@entry=0x7f9b6d416710, new_name=new_name@entry=0x7f9b6d416b18, create_info=create_info@entry=0x7f9b9e074620, table_list=<optimized out>, table_list@entry=0x7f9b6d447118, alter_info=alter_info@entry=0x7f9b9e074550, order_num=0, order=0x0, ignore=false, if_exists=false) at /test/10.5_opt/sql/sql_table.cc:10446
      #11 0x0000561de043dca1 in Sql_cmd_alter_table::execute (this=<optimized out>, thd=0x7f9b6d412018) at /test/10.5_opt/sql/sql_alter.cc:520
      #12 0x0000561de0349fc0 in mysql_execute_command (thd=thd@entry=0x7f9b6d412018) at /test/10.5_opt/sql/sql_parse.cc:5912
      #13 0x0000561de035122c in mysql_parse (thd=0x7f9b6d412018, rawbuf=<optimized out>, length=30, parser_state=0x7f9b9e0754d0, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /test/10.5_opt/sql/sql_parse.cc:7957
      #14 0x0000561de0346855 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7f9b6d412018, packet=packet@entry=0x7f9b6d43a019 "ALTER TABLE t ADD COLUMN c INT", packet_length=packet_length@entry=30, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_opt/sql/sql_parse.cc:1839
      #15 0x0000561de0344ae6 in do_command (thd=0x7f9b6d412018) at /test/10.5_opt/sql/sql_parse.cc:1358
      #16 0x0000561de043929e in do_handle_one_connection (connect=<optimized out>, connect@entry=0x7f9b9bc329b8, put_in_cache=put_in_cache@entry=true) at /test/10.5_opt/sql/sql_connect.cc:1422
      #17 0x0000561de0439444 in handle_one_connection (arg=arg@entry=0x7f9b9bc329b8) at /test/10.5_opt/sql/sql_connect.cc:1319
      #18 0x0000561de07a553a in pfs_spawn_thread (arg=0x7f9b9bc4b018) at /test/10.5_opt/storage/perfschema/pfs.cc:2201
      #19 0x00007f9b9d49d6db in start_thread (arg=0x7f9b9e076700) at pthread_create.c:463
      #20 0x00007f9b9c89b88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

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

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

      Attachments

        Activity

          I see two possible solutions.

          We can skip the changes to the data in commit_try_norebuild().

          We could also refuse any native ALTER TABLE if the data file is not accessible, to be consistent with ALTER TABLE…ALGORITM=COPY, which ought to fail due to the table being inaccessible. I remember that my proposal to do that was rejected several years ago when I was working on MySQL at Oracle. The reasoning was that despite the data file not existing, we can still alter the metadata.

          marko Marko Mäkelä added a comment - I see two possible solutions. We can skip the changes to the data in commit_try_norebuild() . We could also refuse any native ALTER TABLE if the data file is not accessible, to be consistent with ALTER TABLE…ALGORITM=COPY , which ought to fail due to the table being inaccessible. I remember that my proposal to do that was rejected several years ago when I was working on MySQL at Oracle. The reasoning was that despite the data file not existing, we can still alter the metadata.

          The following patch solves the issue and added the test case to imported the instant index also:

          mdev-22446-10.3v1.patch

          thiru Thirunarayanan Balathandayuthapani added a comment - The following patch solves the issue and added the test case to imported the instant index also: mdev-22446-10.3v1.patch

          People

            thiru Thirunarayanan Balathandayuthapani
            Roel Roel Van de Paar
            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.