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

Server crash when renaming the column when FOREIGN_KEY_CHECKS is disabled

Details

    Description

      --source include/have_innodb.inc
       
      CREATE TABLE t1 (f1 INT, f2 INT, f3 INT, KEY idx(f1)) ENGINE=InnoDB;
      ALTER TABLE t1 ADD FOREIGN KEY (f2) REFERENCES t1 (f1);
      ALTER TABLE t1 ADD COLUMN f INT;
      SET FOREIGN_KEY_CHECKS= OFF;
      ALTER TABLE t1 DROP KEY idx;
      ALTER TABLE t1 ADD KEY idx (f1);
      SET FOREIGN_KEY_CHECKS= ON;
      ALTER TABLE t1 DROP f3;
      ALTER TABLE t1 CHANGE f f3 INT;
       
      # Cleanup
      DROP TABLE t1;
      

      10.4 a5ac029f non-debug

      190331 19:44:20 [ERROR] mysqld got signal 11 ;
       
      #2  <signal handler called>
      #3  0x000055e3d35201bd in operator char const* (this=<optimized out>) at /data/src/10.4/storage/innobase/include/dict0mem.h:519
      #4  dict_mem_table_col_rename_low (is_virtual=<optimized out>, s=<optimized out>, to=0x7f5c7c083960 "\001", i=<optimized out>, table=0x7f5c7c08f9e0) at /data/src/10.4/storage/innobase/dict/dict0mem.cc:642
      #5  dict_mem_table_col_rename (table=0x7f5c7c08f9e0, nth_col=<optimized out>, from=<optimized out>, to=<optimized out>, is_virtual=<optimized out>) at /data/src/10.4/storage/innobase/dict/dict0mem.cc:690
      #6  0x000055e3d3387dde in innobase_rename_or_enlarge_columns_cache (user_table=<optimized out>, table=<optimized out>, altered_table=<optimized out>, ha_alter_info=<optimized out>) at /data/src/10.4/storage/innobase/handler/handler0alter.cc:9235
      #7  commit_cache_norebuild (ha_alter_info=ha_alter_info@entry=0x7f5cd5be8e20, ctx=ctx@entry=0x7f5c7c013af8, altered_table=altered_table@entry=0x7f5c7c049138, table=<optimized out>, trx=<optimized out>) at /data/src/10.4/storage/innobase/handler/handler0alter.cc:10362
      #8  0x000055e3d338027c in ha_innobase::commit_inplace_alter_table (this=<optimized out>, altered_table=<optimized out>, ha_alter_info=<optimized out>, commit=<optimized out>) at /data/src/10.4/storage/innobase/handler/handler0alter.cc:11037
      #9  0x000055e3d2e567be in mysql_inplace_alter_table (thd=thd@entry=0x7f5c7c0009a8, table_list=0x7f5c7c012038, table=table@entry=0x7f5c7c0892f8, altered_table=altered_table@entry=0x7f5c7c049138, ha_alter_info=ha_alter_info@entry=0x7f5cd5be8e20, inplace_supported=inplace_supported@entry=HA_ALTER_INPLACE_INSTANT, alter_ctx=0x7f5cd5be9670, target_mdl_request=0x7f5cd5be8ec0) at /data/src/10.4/sql/sql_table.cc:7696
      #10 0x000055e3d2fe29b1 in mysql_alter_table (thd=<optimized out>, new_db=<optimized out>, new_name=<optimized out>, create_info=<optimized out>, table_list=0x7f5c7c012038, alter_info=0x7f5cd5bea170, order_num=0, order=0x0, ignore=false) at /data/src/10.4/sql/sql_table.cc:9934
      #11 0x000055e3d3033aca in Sql_cmd_alter_table::execute (this=0x7f5c7c0930f0, thd=0x7f5c7c0009a8) at /data/src/10.4/sql/sql_alter.cc:496
      #12 0x000055e3d2f4975d in mysql_execute_command (thd=thd@entry=0x7f5c7c0009a8) at /data/src/10.4/sql/sql_parse.cc:6344
      #13 0x000055e3d2f504e1 in mysql_parse (thd=thd@entry=0x7f5c7c0009a8, rawbuf=<optimized out>, length=30, parser_state=parser_state@entry=0x7f5cd5bed1d0, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/src/10.4/sql/sql_parse.cc:8154
      #14 0x000055e3d2f52992 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7f5c7c0009a8, packet=packet@entry=0x7f5c7c009be9 "ALTER TABLE t1 CHANGE f f3 INT", packet_length=packet_length@entry=30, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/src/10.4/sql/sql_parse.cc:1832
      #15 0x000055e3d2f540b7 in do_command (thd=0x7f5c7c0009a8) at /data/src/10.4/sql/sql_parse.cc:1365
      #16 0x000055e3d302f6dc in do_handle_one_connection (connect=connect@entry=0x55e3d5970688) at /data/src/10.4/sql/sql_connect.cc:1398
      #17 0x000055e3d302f844 in handle_one_connection (arg=arg@entry=0x55e3d5970688) at /data/src/10.4/sql/sql_connect.cc:1301
      #18 0x000055e3d334ba44 in pfs_spawn_thread (arg=0x55e3d59706e8) at /data/src/10.4/storage/perfschema/pfs.cc:1862
      #19 0x00007f5cddf65494 in start_thread (arg=0x7f5cd5bee700) at pthread_create.c:333
      #20 0x00007f5cdc13393f in clone () from /lib/x86_64-linux-gnu/libc.so.6
      

      10.4 a5ac029f debug

      mysqld: /data/src/10.4/storage/innobase/dict/dict0mem.cc:633: void dict_mem_table_col_rename_low(dict_table_t*, unsigned int, const char*, const char*, bool): Assertion `foreign->referenced_index != __null' failed.
      190331 19:43:50 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f3aa29b8ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
      #8  0x000055f04330ce14 in dict_mem_table_col_rename_low (table=0x7f3a5013b578, i=6, to=0x7f3a5005e0b7 "f3", s=0x7f3a501550c8 "\003\004", is_virtual=false) at /data/src/10.4/storage/innobase/dict/dict0mem.cc:633
      #9  0x000055f04330d1ae in dict_mem_table_col_rename (table=0x7f3a5013b578, nth_col=2, from=0x7f3a5013cbe7 "f", to=0x7f3a5005e0b7 "f3", is_virtual=false) at /data/src/10.4/storage/innobase/dict/dict0mem.cc:690
      #10 0x000055f04304e5b2 in innobase_rename_or_enlarge_columns_cache (ha_alter_info=0x7f3a9c52e7b0, altered_table=0x7f3a500788f0, table=0x7f3a50063c00, user_table=0x7f3a5013b578) at /data/src/10.4/storage/innobase/handler/handler0alter.cc:9235
      #11 0x000055f043060197 in commit_cache_norebuild (ha_alter_info=0x7f3a9c52e7b0, ctx=0x7f3a50017180, altered_table=0x7f3a500788f0, table=0x7f3a50063c00, trx=0x7f3a9c7c9268) at /data/src/10.4/storage/innobase/handler/handler0alter.cc:10362
      #12 0x000055f043051b75 in ha_innobase::commit_inplace_alter_table (this=0x7f3a5005f148, altered_table=0x7f3a500788f0, ha_alter_info=0x7f3a9c52e7b0, commit=true) at /data/src/10.4/storage/innobase/handler/handler0alter.cc:11037
      #13 0x000055f042cd22cc in handler::ha_commit_inplace_alter_table (this=0x7f3a5005f148, altered_table=0x7f3a500788f0, ha_alter_info=0x7f3a9c52e7b0, commit=true) at /data/src/10.4/sql/handler.cc:4712
      #14 0x000055f042a65803 in mysql_inplace_alter_table (thd=0x7f3a50000b00, table_list=0x7f3a500156c0, table=0x7f3a50063c00, altered_table=0x7f3a500788f0, ha_alter_info=0x7f3a9c52e7b0, inplace_supported=HA_ALTER_INPLACE_INSTANT, target_mdl_request=0x7f3a9c52e9a0, alter_ctx=0x7f3a9c52f100) at /data/src/10.4/sql/sql_table.cc:7696
      #15 0x000055f042a6beac in mysql_alter_table (thd=0x7f3a50000b00, new_db=0x7f3a50005298, new_name=0x7f3a50005698, create_info=0x7f3a9c52fcf0, table_list=0x7f3a500156c0, alter_info=0x7f3a9c52fc30, order_num=0, order=0x0, ignore=false) at /data/src/10.4/sql/sql_table.cc:9934
      #16 0x000055f042afd71b in Sql_cmd_alter_table::execute (this=0x7f3a50015e98, thd=0x7f3a50000b00) at /data/src/10.4/sql/sql_alter.cc:496
      #17 0x000055f04298b49e in mysql_execute_command (thd=0x7f3a50000b00) at /data/src/10.4/sql/sql_parse.cc:6344
      #18 0x000055f042990642 in mysql_parse (thd=0x7f3a50000b00, rawbuf=0x7f3a500155d8 "ALTER TABLE t1 CHANGE f f3 INT", length=30, parser_state=0x7f3a9c531180, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:8154
      #19 0x000055f04297bdd2 in dispatch_command (command=COM_QUERY, thd=0x7f3a50000b00, packet=0x7f3a5000a891 "ALTER TABLE t1 CHANGE f f3 INT", packet_length=30, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1832
      #20 0x000055f04297a5b8 in do_command (thd=0x7f3a50000b00) at /data/src/10.4/sql/sql_parse.cc:1365
      #21 0x000055f042af43d5 in do_handle_one_connection (connect=0x55f0464325f0) at /data/src/10.4/sql/sql_connect.cc:1398
      #22 0x000055f042af4146 in handle_one_connection (arg=0x55f0464325f0) at /data/src/10.4/sql/sql_connect.cc:1301
      #23 0x000055f042fe9e5d in pfs_spawn_thread (arg=0x55f046478450) at /data/src/10.4/storage/perfschema/pfs.cc:1862
      #24 0x00007f3aa48a7494 in start_thread (arg=0x7f3a9c532700) at pthread_create.c:333
      #25 0x00007f3aa2a7593f in clone () from /lib/x86_64-linux-gnu/libc.so.6
      

      Not reproducible on 10.3.

      Slightly different test case with a slightly different assertion failure:

      --source include/have_innodb.inc
       
      CREATE TABLE t1 (f1 INT, f2 INT, KEY idx(f1)) ENGINE=InnoDB;
      SET FOREIGN_KEY_CHECKS= OFF;
      ALTER TABLE t1 ADD FOREIGN KEY (f1) REFERENCES x (x);
      ALTER TABLE t1 ADD COLUMN f INT;
      ALTER TABLE t1 DROP KEY idx;
      ALTER TABLE t1 DROP f2;
      ALTER TABLE t1 CHANGE f f2 INT;
       
      # Cleanup
      DROP TABLE t1;
      

      10.4 a5ac029f debug

      mysqld: /data/src/10.4/storage/innobase/dict/dict0mem.cc:608: void dict_mem_table_col_rename_low(dict_table_t*, unsigned int, const char*, const char*, bool): Assertion `new_index != __null' failed.
      190331 19:56:57 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f7a77500ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
      #8  0x0000560c5368ecc5 in dict_mem_table_col_rename_low (table=0x7f7a2419b8c8, i=5, to=0x7f7a24072f84 "f2", s=0x7f7a2419be05 "", is_virtual=false) at /data/src/10.4/storage/innobase/dict/dict0mem.cc:608
      #9  0x0000560c5368f1ae in dict_mem_table_col_rename (table=0x7f7a2419b8c8, nth_col=1, from=0x7f7a2419cb64 "f", to=0x7f7a24072f84 "f2", is_virtual=false) at /data/src/10.4/storage/innobase/dict/dict0mem.cc:690
      #10 0x0000560c533d05b2 in innobase_rename_or_enlarge_columns_cache (ha_alter_info=0x7f7a708767b0, altered_table=0x7f7a24071b00, table=0x7f7a24150720, user_table=0x7f7a2419b8c8) at /data/src/10.4/storage/innobase/handler/handler0alter.cc:9235
      #11 0x0000560c533e2197 in commit_cache_norebuild (ha_alter_info=0x7f7a708767b0, ctx=0x7f7a24016c28, altered_table=0x7f7a24071b00, table=0x7f7a24150720, trx=0x7f7a71311268) at /data/src/10.4/storage/innobase/handler/handler0alter.cc:10362
      #12 0x0000560c533d3b75 in ha_innobase::commit_inplace_alter_table (this=0x7f7a24151588, altered_table=0x7f7a24071b00, ha_alter_info=0x7f7a708767b0, commit=true) at /data/src/10.4/storage/innobase/handler/handler0alter.cc:11037
      #13 0x0000560c530542cc in handler::ha_commit_inplace_alter_table (this=0x7f7a24151588, altered_table=0x7f7a24071b00, ha_alter_info=0x7f7a708767b0, commit=true) at /data/src/10.4/sql/handler.cc:4712
      #14 0x0000560c52de7803 in mysql_inplace_alter_table (thd=0x7f7a24000b00, table_list=0x7f7a240156c0, table=0x7f7a24150720, altered_table=0x7f7a24071b00, ha_alter_info=0x7f7a708767b0, inplace_supported=HA_ALTER_INPLACE_INSTANT, target_mdl_request=0x7f7a708769a0, alter_ctx=0x7f7a70877100) at /data/src/10.4/sql/sql_table.cc:7696
      #15 0x0000560c52dedeac in mysql_alter_table (thd=0x7f7a24000b00, new_db=0x7f7a24005298, new_name=0x7f7a24005698, create_info=0x7f7a70877cf0, table_list=0x7f7a240156c0, alter_info=0x7f7a70877c30, order_num=0, order=0x0, ignore=false) at /data/src/10.4/sql/sql_table.cc:9934
      #16 0x0000560c52e7f71b in Sql_cmd_alter_table::execute (this=0x7f7a24015e98, thd=0x7f7a24000b00) at /data/src/10.4/sql/sql_alter.cc:496
      #17 0x0000560c52d0d49e in mysql_execute_command (thd=0x7f7a24000b00) at /data/src/10.4/sql/sql_parse.cc:6344
      #18 0x0000560c52d12642 in mysql_parse (thd=0x7f7a24000b00, rawbuf=0x7f7a240155d8 "ALTER TABLE t1 CHANGE f f2 INT", length=30, parser_state=0x7f7a70879180, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:8154
      #19 0x0000560c52cfddd2 in dispatch_command (command=COM_QUERY, thd=0x7f7a24000b00, packet=0x7f7a2400a891 "ALTER TABLE t1 CHANGE f f2 INT", packet_length=30, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1832
      #20 0x0000560c52cfc5b8 in do_command (thd=0x7f7a24000b00) at /data/src/10.4/sql/sql_parse.cc:1365
      #21 0x0000560c52e763d5 in do_handle_one_connection (connect=0x560c568c42c0) at /data/src/10.4/sql/sql_connect.cc:1398
      #22 0x0000560c52e76146 in handle_one_connection (arg=0x560c568c42c0) at /data/src/10.4/sql/sql_connect.cc:1301
      #23 0x0000560c5336be5d in pfs_spawn_thread (arg=0x560c5690a120) at /data/src/10.4/storage/perfschema/pfs.cc:1862
      #24 0x00007f7a793ef494 in start_thread (arg=0x7f7a7087a700) at pthread_create.c:333
      #25 0x00007f7a775bd93f in clone () from /lib/x86_64-linux-gnu/libc.so.6
      

      Attachments

        Activity

          I've got a test case which causes seemingly the same failure on all 10.x, so I'm adjusting affected/fix versions accordingly:

          --source include/have_innodb.inc
           
          CREATE TABLE t1 (a INT, b INT, KEY idx(a)) ENGINE=InnoDB;
          SET FOREIGN_KEY_CHECKS= OFF;
          ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES tx(x);
          ALTER TABLE t1 DROP KEY idx;
          ALTER TABLE t1 CHANGE b c INT;
           
          # Cleanup
          DROP TABLE t1;
          

          10.1 409dddf6

          2019-04-15 16:35:39 7fd2c3b61700  InnoDB: Assertion failure in thread 140543203350272 in file dict0mem.cc line 424
          InnoDB: Failing assertion: new_index != __null
           
          #5  0x00007fd2c16d73fa in abort () from /lib/x86_64-linux-gnu/libc.so.6
          #6  0x00007fd2baa7cf4b in dict_mem_table_col_rename_low (table=0x7fd2bc3b0678, i=1, to=0x7fd2ab443770 "c", s=0x7fd2ab469112 "c") at /data/src/10.1/storage/innobase/dict/dict0mem.cc:424
          #7  0x00007fd2baa7d331 in dict_mem_table_col_rename (table=0x7fd2bc3b0678, nth_col=1, from=0x7fd2b7eeaa03 "b", to=0x7fd2ab443770 "c") at /data/src/10.1/storage/innobase/dict/dict0mem.cc:503
          #8  0x00007fd2bab1f076 in innobase_rename_columns_cache (ha_alter_info=0x7fd2c3b5d650, table=0x7fd2ab481c70, user_table=0x7fd2bc3b0678) at /data/src/10.1/storage/innobase/handler/handler0alter.cc:4888
          #9  0x00007fd2bab21301 in ha_innodb::commit_inplace_alter_table (this=0x7fd2ab4b2088, altered_table=0x7fd2ab68f070, ha_alter_info=0x7fd2c3b5d650, commit=true) at /data/src/10.1/storage/innobase/handler/handler0alter.cc:6169
          #10 0x00005651f4f41209 in handler::ha_commit_inplace_alter_table (this=0x7fd2ab4b2088, altered_table=0x7fd2ab68f070, ha_alter_info=0x7fd2c3b5d650, commit=true) at /data/src/10.1/sql/handler.cc:4257
          #11 0x00005651f4dbb6f4 in mysql_inplace_alter_table (thd=0x7fd2b7f7d070, table_list=0x7fd2ab443170, table=0x7fd2ab481c70, altered_table=0x7fd2ab68f070, ha_alter_info=0x7fd2c3b5d650, inplace_supported=HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE, target_mdl_request=0x7fd2c3b5d780, alter_ctx=0x7fd2c3b5e320) at /data/src/10.1/sql/sql_table.cc:7210
          #12 0x00005651f4dc0064 in mysql_alter_table (thd=0x7fd2b7f7d070, new_db=0x7fd2ab443760 "test", new_name=0x0, create_info=0x7fd2c3b5ef10, table_list=0x7fd2ab443170, alter_info=0x7fd2c3b5ee80, order_num=0, order=0x0, ignore=false) at /data/src/10.1/sql/sql_table.cc:9036
          #13 0x00005651f4e31e44 in Sql_cmd_alter_table::execute (this=0x7fd2ab443858, thd=0x7fd2b7f7d070) at /data/src/10.1/sql/sql_alter.cc:328
          #14 0x00005651f4d0007c in mysql_execute_command (thd=0x7fd2b7f7d070) at /data/src/10.1/sql/sql_parse.cc:5695
          #15 0x00005651f4d04937 in mysql_parse (thd=0x7fd2b7f7d070, rawbuf=0x7fd2ab443088 "ALTER TABLE t1 CHANGE b c INT", length=29, parser_state=0x7fd2c3b601e0) at /data/src/10.1/sql/sql_parse.cc:7462
          #16 0x00005651f4cf3305 in dispatch_command (command=COM_QUERY, thd=0x7fd2b7f7d070, packet=0x7fd2b7e9b071 "ALTER TABLE t1 CHANGE b c INT", packet_length=29) at /data/src/10.1/sql/sql_parse.cc:1499
          #17 0x00005651f4cf2090 in do_command (thd=0x7fd2b7f7d070) at /data/src/10.1/sql/sql_parse.cc:1131
          #18 0x00005651f4e2d365 in do_handle_one_connection (thd_arg=0x7fd2b7f7d070) at /data/src/10.1/sql/sql_connect.cc:1330
          #19 0x00005651f4e2d0c9 in handle_one_connection (arg=0x7fd2b7f7d070) at /data/src/10.1/sql/sql_connect.cc:1242
          #20 0x00005651f51eb81a in pfs_spawn_thread (arg=0x7fd2bc3b0670) at /data/src/10.1/storage/perfschema/pfs.cc:1861
          #21 0x00007fd2c37f0494 in start_thread (arg=0x7fd2c3b61700) at pthread_create.c:333
          #22 0x00007fd2c178b93f in clone () from /lib/x86_64-linux-gnu/libc.so.6
          

          elenst Elena Stepanova added a comment - I've got a test case which causes seemingly the same failure on all 10.x, so I'm adjusting affected/fix versions accordingly: --source include/have_innodb.inc   CREATE TABLE t1 (a INT , b INT , KEY idx(a)) ENGINE=InnoDB; SET FOREIGN_KEY_CHECKS= OFF ; ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES tx(x); ALTER TABLE t1 DROP KEY idx; ALTER TABLE t1 CHANGE b c INT ;   # Cleanup DROP TABLE t1; 10.1 409dddf6 2019-04-15 16:35:39 7fd2c3b61700 InnoDB: Assertion failure in thread 140543203350272 in file dict0mem.cc line 424 InnoDB: Failing assertion: new_index != __null   #5 0x00007fd2c16d73fa in abort () from /lib/x86_64-linux-gnu/libc.so.6 #6 0x00007fd2baa7cf4b in dict_mem_table_col_rename_low (table=0x7fd2bc3b0678, i=1, to=0x7fd2ab443770 "c", s=0x7fd2ab469112 "c") at /data/src/10.1/storage/innobase/dict/dict0mem.cc:424 #7 0x00007fd2baa7d331 in dict_mem_table_col_rename (table=0x7fd2bc3b0678, nth_col=1, from=0x7fd2b7eeaa03 "b", to=0x7fd2ab443770 "c") at /data/src/10.1/storage/innobase/dict/dict0mem.cc:503 #8 0x00007fd2bab1f076 in innobase_rename_columns_cache (ha_alter_info=0x7fd2c3b5d650, table=0x7fd2ab481c70, user_table=0x7fd2bc3b0678) at /data/src/10.1/storage/innobase/handler/handler0alter.cc:4888 #9 0x00007fd2bab21301 in ha_innodb::commit_inplace_alter_table (this=0x7fd2ab4b2088, altered_table=0x7fd2ab68f070, ha_alter_info=0x7fd2c3b5d650, commit=true) at /data/src/10.1/storage/innobase/handler/handler0alter.cc:6169 #10 0x00005651f4f41209 in handler::ha_commit_inplace_alter_table (this=0x7fd2ab4b2088, altered_table=0x7fd2ab68f070, ha_alter_info=0x7fd2c3b5d650, commit=true) at /data/src/10.1/sql/handler.cc:4257 #11 0x00005651f4dbb6f4 in mysql_inplace_alter_table (thd=0x7fd2b7f7d070, table_list=0x7fd2ab443170, table=0x7fd2ab481c70, altered_table=0x7fd2ab68f070, ha_alter_info=0x7fd2c3b5d650, inplace_supported=HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE, target_mdl_request=0x7fd2c3b5d780, alter_ctx=0x7fd2c3b5e320) at /data/src/10.1/sql/sql_table.cc:7210 #12 0x00005651f4dc0064 in mysql_alter_table (thd=0x7fd2b7f7d070, new_db=0x7fd2ab443760 "test", new_name=0x0, create_info=0x7fd2c3b5ef10, table_list=0x7fd2ab443170, alter_info=0x7fd2c3b5ee80, order_num=0, order=0x0, ignore=false) at /data/src/10.1/sql/sql_table.cc:9036 #13 0x00005651f4e31e44 in Sql_cmd_alter_table::execute (this=0x7fd2ab443858, thd=0x7fd2b7f7d070) at /data/src/10.1/sql/sql_alter.cc:328 #14 0x00005651f4d0007c in mysql_execute_command (thd=0x7fd2b7f7d070) at /data/src/10.1/sql/sql_parse.cc:5695 #15 0x00005651f4d04937 in mysql_parse (thd=0x7fd2b7f7d070, rawbuf=0x7fd2ab443088 "ALTER TABLE t1 CHANGE b c INT", length=29, parser_state=0x7fd2c3b601e0) at /data/src/10.1/sql/sql_parse.cc:7462 #16 0x00005651f4cf3305 in dispatch_command (command=COM_QUERY, thd=0x7fd2b7f7d070, packet=0x7fd2b7e9b071 "ALTER TABLE t1 CHANGE b c INT", packet_length=29) at /data/src/10.1/sql/sql_parse.cc:1499 #17 0x00005651f4cf2090 in do_command (thd=0x7fd2b7f7d070) at /data/src/10.1/sql/sql_parse.cc:1131 #18 0x00005651f4e2d365 in do_handle_one_connection (thd_arg=0x7fd2b7f7d070) at /data/src/10.1/sql/sql_connect.cc:1330 #19 0x00005651f4e2d0c9 in handle_one_connection (arg=0x7fd2b7f7d070) at /data/src/10.1/sql/sql_connect.cc:1242 #20 0x00005651f51eb81a in pfs_spawn_thread (arg=0x7fd2bc3b0670) at /data/src/10.1/storage/perfschema/pfs.cc:1861 #21 0x00007fd2c37f0494 in start_thread (arg=0x7fd2c3b61700) at pthread_create.c:333 #22 0x00007fd2c178b93f in clone () from /lib/x86_64-linux-gnu/libc.so.6

          The following patch could solve the issue:

          diff --git a/mysql-test/suite/innodb/r/foreign_key.result b/mysql-test/suite/i
          nnodb/r/foreign_key.result
          index 5eb0658bf48..f59f878bc84 100644
          --- a/mysql-test/suite/innodb/r/foreign_key.result
          +++ b/mysql-test/suite/innodb/r/foreign_key.result
          @@ -522,3 +522,10 @@ test.t1    check   status  OK
           DROP TABLE t1;
           SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
           # End of 10.2 tests
          +CREATE TABLE t1 (a INT, b INT, KEY idx(a)) ENGINE=InnoDB;
          +SET FOREIGN_KEY_CHECKS= OFF;
          +ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES tx(x);
          +ALTER TABLE t1 DROP KEY idx;
          +ALTER TABLE t1 CHANGE a c INT;
          +DROP TABLE t1;
          +SET FOREIGN_KEY_CHECKS=1;
          diff --git a/mysql-test/suite/innodb/t/foreign_key.test b/mysql-test/suite/inn
          odb/t/foreign_key.test
          index 06cab983656..0a733b0c761 100644
          --- a/mysql-test/suite/innodb/t/foreign_key.test
          +++ b/mysql-test/suite/innodb/t/foreign_key.test
          @@ -498,4 +498,15 @@ SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
           
           --echo # End of 10.2 tests
           
          +# MDEV-19092 Server crash when renaming the column when
          +# FOREIGN_KEY_CHECKS is disabled
          +CREATE TABLE t1 (a INT, b INT, KEY idx(a)) ENGINE=InnoDB;
          +SET FOREIGN_KEY_CHECKS= OFF;
          +ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES tx(x);
          +ALTER TABLE t1 DROP KEY idx;
          +ALTER TABLE t1 CHANGE a c INT;
          +# Cleanup
          +DROP TABLE t1;
          +SET FOREIGN_KEY_CHECKS=1;
          +
           --source include/wait_until_count_sessions.inc
          diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc
          index fe01948b70d..1b96243fb3d 100644
          --- a/storage/innobase/dict/dict0mem.cc
          +++ b/storage/innobase/dict/dict0mem.cc
          @@ -564,9 +564,10 @@ dict_mem_table_col_rename_low(
                                          foreign->foreign_col_names,
                                          foreign->n_fields, NULL, true, false,
                                          NULL, NULL, NULL);
          -                       /* There must be an equivalent index in this case. */
          -                       ut_ad(new_index != NULL);
           
          +                       /* New index can be null if InnoDB already dropped
          +                       the foreign index when FOREIGN_KEY_CHECKS
          +                       is disabled */
                                  foreign->foreign_index = new_index;
           
                          } else {
          

          thiru Thirunarayanan Balathandayuthapani added a comment - The following patch could solve the issue: diff --git a/mysql-test/suite/innodb/r/foreign_key.result b/mysql-test/suite/i nnodb/r/foreign_key.result index 5eb0658bf48..f59f878bc84 100644 --- a/mysql-test/suite/innodb/r/foreign_key.result +++ b/mysql-test/suite/innodb/r/foreign_key.result @@ -522,3 +522,10 @@ test.t1 check status OK DROP TABLE t1; SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency; # End of 10.2 tests +CREATE TABLE t1 (a INT, b INT, KEY idx(a)) ENGINE=InnoDB; +SET FOREIGN_KEY_CHECKS= OFF; +ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES tx(x); +ALTER TABLE t1 DROP KEY idx; +ALTER TABLE t1 CHANGE a c INT; +DROP TABLE t1; +SET FOREIGN_KEY_CHECKS=1; diff --git a/mysql-test/suite/innodb/t/foreign_key.test b/mysql-test/suite/inn odb/t/foreign_key.test index 06cab983656..0a733b0c761 100644 --- a/mysql-test/suite/innodb/t/foreign_key.test +++ b/mysql-test/suite/innodb/t/foreign_key.test @@ -498,4 +498,15 @@ SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency; --echo # End of 10.2 tests +# MDEV-19092 Server crash when renaming the column when +# FOREIGN_KEY_CHECKS is disabled +CREATE TABLE t1 (a INT, b INT, KEY idx(a)) ENGINE=InnoDB; +SET FOREIGN_KEY_CHECKS= OFF; +ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES tx(x); +ALTER TABLE t1 DROP KEY idx; +ALTER TABLE t1 CHANGE a c INT; +# Cleanup +DROP TABLE t1; +SET FOREIGN_KEY_CHECKS=1; + --source include/wait_until_count_sessions.inc diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc index fe01948b70d..1b96243fb3d 100644 --- a/storage/innobase/dict/dict0mem.cc +++ b/storage/innobase/dict/dict0mem.cc @@ -564,9 +564,10 @@ dict_mem_table_col_rename_low( foreign->foreign_col_names, foreign->n_fields, NULL, true, false, NULL, NULL, NULL); - /* There must be an equivalent index in this case. */ - ut_ad(new_index != NULL); + /* New index can be null if InnoDB already dropped + the foreign index when FOREIGN_KEY_CHECKS + is disabled */ foreign->foreign_index = new_index; } else {

          thiru, please post the fix and test case for 10.1. While the test case in Description passes on 10.1, the one in a later comment by elenst crashes both InnoDB and XtraDB.

          marko Marko Mäkelä added a comment - thiru , please post the fix and test case for 10.1. While the test case in Description passes on 10.1, the one in a later comment by elenst crashes both InnoDB and XtraDB.

          The very first test case from the description still fails on 10.4 b6344698, which according to the commit log has the patch for this bug.

          elenst Elena Stepanova added a comment - The very first test case from the description still fails on 10.4 b6344698, which according to the commit log has the patch for this bug.

          Add the patch to address referenced index failure. Patch is in bb-10.1-MDEV-19092

          thiru Thirunarayanan Balathandayuthapani added a comment - Add the patch to address referenced index failure. Patch is in bb-10.1- MDEV-19092

          People

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