Bug #88046 InnoDB: ALTER TABLE ... CHANGE ... cause mysql server crash
Submitted: 10 Oct 2017 13:50 Modified: 10 Oct 2017 16:50
Reporter: kfpanda kf Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: DDL Severity:S6 (Debug Builds)
Version:5.6.37 OS:Linux
Assigned to: CPU Architecture:Any
Tags: debug

[10 Oct 2017 13:50] kfpanda kf
Description:
#0  0x00007f99a4590741 in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000ab68b6 in my_write_core (sig=6) at /sda/src/rds-mysql/mysys/stacktrace.c:424
#2  0x000000000073403c in handle_fatal_signal (sig=6) at /sda/src/rds-mysql/sql/signal_handler.cc:230
#3  <signal handler called>
#4  0x00007f99a359c5f7 in raise () from /lib64/libc.so.6
#5  0x00007f99a359dce8 in abort () from /lib64/libc.so.6
#6  0x0000000000bb68f7 in ha_innobase::commit_inplace_alter_table (this=0x7f996c126630, altered_table=0x7f996c25f8d0, ha_alter_info=0x7f998f6f8b20, commit=true) at /sda/src/rds-mysql/storage/innobase/handler/handler0alter.cc:5826
#7  0x000000000064bb79 in handler::ha_commit_inplace_alter_table (this=0x7f996c126630, altered_table=0x7f996c25f8d0, ha_alter_info=0x7f998f6f8b20, commit=true) at /sda/src/rds-mysql/sql/handler.cc:4390
#8  0x0000000000852d8d in mysql_inplace_alter_table (thd=0x35459a0, table_list=0x7f996c005210, table=0x7f996c17ac00, altered_table=0x7f996c25f8d0, ha_alter_info=0x7f998f6f8b20, inplace_supported=HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE, 
    target_mdl_request=0x7f998f6f8570, alter_ctx=0x7f998f6f9080) at /sda/src/rds-mysql/sql/sql_table.cc:6727
#9  0x0000000000857053 in mysql_alter_table (thd=0x35459a0, new_db=0x7f996c005770 "test", new_name=0x0, create_info=0x7f998f6f9f10, table_list=0x7f996c005210, alter_info=0x7f998f6f9e80, order_num=0, order=0x0, ignore=false) at /sda/src/rds-mysql/sql/sql_table.cc:8554
#10 0x0000000000997e53 in Sql_cmd_alter_table::execute (this=0x7f996c005908, thd=0x35459a0) at /sda/src/rds-mysql/sql/sql_alter.cc:313
#11 0x00000000007e9728 in mysql_execute_command (thd=0x35459a0) at /sda/src/rds-mysql/sql/sql_parse.cc:5077
#12 0x00000000007ecb68 in mysql_parse (thd=0x35459a0, rawbuf=0x7f996c0050e0 "ALTER TABLE child CHANGE a2 a2_new INT, CHANGE a1 a1_new INT", length=60, parser_state=0x7f998f6fb6d0) at /sda/src/rds-mysql/sql/sql_parse.cc:6489
#13 0x00000000007df8e2 in dispatch_command (command=COM_QUERY, thd=0x35459a0, packet=0x3e503a1 "ALTER TABLE child CHANGE a2 a2_new INT, CHANGE a1 a1_new INT;", packet_length=61) at /sda/src/rds-mysql/sql/sql_parse.cc:1377
#14 0x00000000007de914 in do_command (thd=0x35459a0) at /sda/src/rds-mysql/sql/sql_parse.cc:1040
#15 0x00000000007a5ee1 in do_handle_one_connection (thd_arg=0x35459a0) at /sda/src/rds-mysql/sql/sql_connect.cc:982
#16 0x00000000007a5c7e in handle_one_connection (arg=0x35459a0) at /sda/src/rds-mysql/sql/sql_connect.cc:899
#17 0x0000000000b64db5 in pfs_spawn_thread (arg=0x3bf5d50) at /sda/src/rds-mysql/storage/perfschema/pfs.cc:1860
#18 0x00007f99a458bdc5 in start_thread () from /lib64/libpthread.so.0
#19 0x00007f99a365d21d in clone () from /lib64/libc.so.6

How to repeat:
CREATE TABLE t1(a1 INT NOT NULL,a2 INT,a3 INT)ENGINE=InnoDB;
SET @@SESSION.foreign_key_checks=OFF;
ALTER TABLE t1 ADD CONSTRAINT fk_4 FOREIGN KEY(a1,a2)REFERENCES parent(a,b) ON DELETE CASCADE ON UPDATE CASCADE,ALGORITHM=INPLACE;
ALTER TABLE t1 CHANGE a2 a2_new INT,CHANGE a1 a1_new INT;
[10 Oct 2017 16:50] MySQL Verification Team
Thank you for the bug report . According your own comment, duplicate of bug https://bugs.mysql.com/bug.php?id=83799 which produces same callstack on debug server.

2017-10-10 13:29:38 6280 [Note] c:\dbs\5.6\bin\mysqld: ready for connections.
Version: '5.6.39-debug-log'  socket: ''  port: 3560  Source distribution 2017-OCT-01
2017-10-10 13:30:47 6280 [ERROR] InnoDB: dict_load_foreigns() returned 38 for ALTER TABLE t1 CHANGE a2 a2_new INT,CHANGE a1 a1_new INT
2017-10-10 13:30:47 1a94  InnoDB: Assertion failure in thread 6804 in file handler0alter.cc line 5866
<cut>
Thread pointer: 0x2b5d2ad2360
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
7ff7a91e5205    mysqld.exe!my_sigabrt_handler()[my_thr_init.c:455]
7ffc1192fe21    ucrtbased.dll!raise()
7ffc11931979    ucrtbased.dll!abort()
7ff7a94f2032    mysqld.exe!ha_innobase::commit_inplace_alter_table()[handler0alter.cc:5866]
7ff7a8ced64b    mysqld.exe!handler::ha_commit_inplace_alter_table()[handler.cc:4388]
7ff7a8e70114    mysqld.exe!mysql_inplace_alter_table()[sql_table.cc:6727]
7ff7a8e5cf54    mysqld.exe!mysql_alter_table()[sql_table.cc:8554]
7ff7a8fe9c9e    mysqld.exe!Sql_cmd_alter_table::execute()[sql_alter.cc:307]
7ff7a8e222a3    mysqld.exe!mysql_execute_command()[sql_parse.cc:5026]
7ff7a8e1a4e2    mysqld.exe!mysql_parse()[sql_parse.cc:6444]
7ff7a8e23d5b    mysqld.exe!dispatch_command()[sql_parse.cc:1376]
7ff7a8e22db7    mysqld.exe!do_command()[sql_parse.cc:1039]
7ff7a8e743f2    mysqld.exe!do_handle_one_connection()[sql_connect.cc:982]
7ff7a8e74222    mysqld.exe!handle_one_connection()[sql_connect.cc:900]
7ff7a96a3b25    mysqld.exe!pfs_spawn_thread()[pfs.cc:1863]
7ff7a91e3797    mysqld.exe!pthread_start()[my_winthread.c:62]
7ffc11938d48    ucrtbased.dll!_register_onexit_function()
7ffc11938991    ucrtbased.dll!_register_onexit_function()
7ffc5cb02774    KERNEL32.DLL!BaseThreadInitThunk()
7ffc5e110d51    ntdll.dll!RtlUserThreadStart()

mysql 5.6 > DROP DATABASE test;CREATE DATABASE test;USE test;
Query OK, 2 rows affected (0.04 sec)

Query OK, 1 row affected (0.00 sec)

Database changed
mysql 5.6 > SET DEBUG='+d,innodb_test_open_ref_fail';
Query OK, 0 rows affected (0.00 sec)

mysql 5.6 > SET @@SESSION.foreign_key_checks=0;
Query OK, 0 rows affected (0.00 sec)

mysql 5.6 > CREATE TABLE t2(b INT,c INT);
Query OK, 0 rows affected (0.04 sec)

mysql 5.6 > alter table t2 add constraint b foreign key(b)references t2(b);
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql 5.6 >

2017-10-10 13:39:40 fac  InnoDB: Assertion failure in thread 4012 in file handler0alter.cc line 5866                            
                                                   
where mysqld died. If you see no messages after this, something went                                                            
terribly wrong...                                                                                                               
7ff7a91e5205    mysqld.exe!my_sigabrt_handler()[my_thr_init.c:455]                                                              
7ffc11d2fe21    ucrtbased.dll!raise()                                                                                           
7ffc11d31979    ucrtbased.dll!abort()                                                                                           
7ff7a94f2032    mysqld.exe!ha_innobase::commit_inplace_alter_table()[handler0alter.cc:5866]                                     
7ff7a8ced64b    mysqld.exe!handler::ha_commit_inplace_alter_table()[handler.cc:4388]                                            
7ff7a8e70114    mysqld.exe!mysql_inplace_alter_table()[sql_table.cc:6727]                                                       
7ff7a8e5cf54    mysqld.exe!mysql_alter_table()[sql_table.cc:8554]                                                               
7ff7a8fe9c9e    mysqld.exe!Sql_cmd_alter_table::execute()[sql_alter.cc:307]                                                     
7ff7a8e222a3    mysqld.exe!mysql_execute_command()[sql_parse.cc:5026]                                                           
7ff7a8e1a4e2    mysqld.exe!mysql_parse()[sql_parse.cc:6444]                                                                     
7ff7a8e23d5b    mysqld.exe!dispatch_command()[sql_parse.cc:1376]                                                                
7ff7a8e22db7    mysqld.exe!do_command()[sql_parse.cc:1039]                                                                      
7ff7a8e743f2    mysqld.exe!do_handle_one_connection()[sql_connect.cc:982]                                                       
7ff7a8e74222    mysqld.exe!handle_one_connection()[sql_connect.cc:900]                                                          
7ff7a96a3b25    mysqld.exe!pfs_spawn_thread()[pfs.cc:1863]                                                                      
7ff7a91e3797    mysqld.exe!pthread_start()[my_winthread.c:62]                                                                   
7ffc11d38d48    ucrtbased.dll!_register_onexit_function()                                                                       
7ffc11d38991    ucrtbased.dll!_register_onexit_function()                                                                       
7ffc5cb02774    KERNEL32.DLL!BaseThreadInitThunk()                                                                              
7ffc5e110d51    ntdll.dll!RtlUserThreadStart()