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

Server crashes in check_col_is_in_fk_indexes upon non-copying column modification

    XMLWordPrintable

Details

    Description

      --source include/have_innodb.inc
       
      SET SESSION FOREIGN_KEY_CHECKS = OFF;
      CREATE TABLE t1 (a INT, FOREIGN KEY(a) REFERENCES t2(x)) ENGINE=InnoDB;
      CREATE TABLE t2 (b VARCHAR(8)) ENGINE=InnoDB;
      ALTER TABLE t2 MODIFY b VARCHAR(16);
       
      # Cleanup
      DROP TABLE t1, t2;
      

      10.6 a60462d9

      #3  <signal handler called>
      #4  0x000055c5b81a032a in check_col_is_in_fk_indexes (table=0x618000037d20, col=0x61c000037920, col_name=0x6190000dfd89 "b", drop_fk=..., add_fk=...) at /data/src/10.6/storage/innobase/handler/handler0alter.cc:7779
      #5  0x000055c5b81a732b in ha_innobase::prepare_inplace_alter_table (this=0x61d0002a8ab8, altered_table=0x7f6106b02340, ha_alter_info=0x7f6106b017c0) at /data/src/10.6/storage/innobase/handler/handler0alter.cc:8416
      #6  0x000055c5b76cf377 in handler::ha_prepare_inplace_alter_table (this=0x61d0002a8ab8, altered_table=0x7f6106b02340, ha_alter_info=0x7f6106b017c0) at /data/src/10.6/sql/handler.cc:5267
      #7  0x000055c5b70de089 in mysql_inplace_alter_table (thd=0x62b0000bd218, table_list=0x62b0000c4358, table=0x6190000e0198, altered_table=0x7f6106b02340, ha_alter_info=0x7f6106b017c0, target_mdl_request=0x7f6106b018c0, ddl_log_state=0x7f6106b014f0, trigger_param=0x7f6106b027c0, alter_ctx=0x7f6106b032c0) at /data/src/10.6/sql/sql_table.cc:7361
      #8  0x000055c5b70f559d in mysql_alter_table (thd=0x62b0000bd218, new_db=0x62b0000c1e80, new_name=0x62b0000c22d8, create_info=0x7f6106b04280, table_list=0x62b0000c4358, recreate_info=0x7f6106b04090, alter_info=0x7f6106b04130, order_num=0, order=0x0, ignore=false, if_exists=false) at /data/src/10.6/sql/sql_table.cc:10370
      #9  0x000055c5b72b86b7 in Sql_cmd_alter_table::execute (this=0x62b0000c4bb8, thd=0x62b0000bd218) at /data/src/10.6/sql/sql_alter.cc:597
      #10 0x000055c5b6e4e400 in mysql_execute_command (thd=0x62b0000bd218, is_called_from_prepared_stmt=false) at /data/src/10.6/sql/sql_parse.cc:6024
      #11 0x000055c5b6e5b827 in mysql_parse (thd=0x62b0000bd218, rawbuf=0x62b0000c4238 "ALTER TABLE t2 MODIFY b VARCHAR(16)", length=35, parser_state=0x7f6106b059f0) at /data/src/10.6/sql/sql_parse.cc:8053
      #12 0x000055c5b6e314e8 in dispatch_command (command=COM_QUERY, thd=0x62b0000bd218, packet=0x629000280219 "ALTER TABLE t2 MODIFY b VARCHAR(16)", packet_length=35, blocking=true) at /data/src/10.6/sql/sql_parse.cc:1896
      #13 0x000055c5b6e2e21c in do_command (thd=0x62b0000bd218, blocking=true) at /data/src/10.6/sql/sql_parse.cc:1409
      #14 0x000055c5b729a6ec in do_handle_one_connection (connect=0x608000003938, put_in_cache=true) at /data/src/10.6/sql/sql_connect.cc:1416
      #15 0x000055c5b729a0ad in handle_one_connection (arg=0x6080000038b8) at /data/src/10.6/sql/sql_connect.cc:1318
      #16 0x000055c5b7ef6b14 in pfs_spawn_thread (arg=0x617000008218) at /data/src/10.6/storage/perfschema/pfs.cc:2201
      #17 0x00007f61182a7fd4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #18 0x00007f61183285bc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      Reproducible on 10.6+, debug- and non-debug alike.

      The crash started happening on 10.6 after this merge in 10.6.15:

      commit 6bf8483cac34651f331bc2dece91580b003cf3a4
      Merge: 72928e640e6 65405308a13
      Author: Oleksandr Byelkin
      Date:   Tue Aug 1 15:08:52 2023 +0200
       
          Merge branch '10.5' into 10.6
      

      Since the behavior on 10.4-10.5 hasn't changed, I cannot bisect them. It's a sizeable merge, there can be various reasons. One possible suspect is

      commit 5f09b53bdb4e973e7c7ec2c53a24c98321223f98
      Author: Thirunarayanan Balathandayuthapani
      Date:   Mon Jun 5 19:09:38 2023 +0530
       
          MDEV-31086 MODIFY COLUMN can break FK constraints, and lead to unrestorable dumps
      

      A little more meaningful test case,

      --source include/have_innodb.inc
       
      SET SESSION FOREIGN_KEY_CHECKS = OFF;
      CREATE TABLE t1 (a VARCHAR(16) KEY, FOREIGN KEY(a) REFERENCES t2(b)) ENGINE=InnoDB;
      CREATE TABLE t2 (b VARCHAR(8)) ENGINE=InnoDB;
       
      SET SESSION FOREIGN_KEY_CHECKS = ON;
      ALTER TABLE t2 MODIFY b VARCHAR(16), ADD KEY(b);
       
      # Cleanup
      DROP TABLE t1, t2;
      

      Attachments

        Issue Links

          Activity

            People

              thiru Thirunarayanan Balathandayuthapani
              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.