Bug #6720 alter table engine=innodb crashes the server
Submitted: 19 Nov 2004 12:59 Modified: 19 Nov 2004 13:38
Reporter: Sergey Petrunya Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:5.0-bk OS:Linux (Linux and win32)
Assigned to: CPU Architecture:Any

[19 Nov 2004 12:59] Sergey Petrunya
Description:
Attempt to convert a MyISAM table to InnoDB causes crash, both on linux and win32 

How to repeat:
Put the file somewhere in the database (I'll attach the table file)
try to run 
"alter table t0innodb engine=innodb"
and get the following:

041119 16:00:28  InnoDB: Started; log sequence number 0 1613211
[New Thread 65545 (LWP 30459)]
/dbdata/psergey/mysql-5.0-nov-clean-valgrind/sql/mysqld: ready for connections.
Version: '5.0.2-alpha-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
[New Thread 73738 (LWP 30460)]
041119 16:00:39InnoDB: Assertion failure in thread 73738 in file ha_innodb.cc line 2408
InnoDB: Failing assertion: prebuilt->trx->mysql_n_tables_locked == 2
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/mysql/en/Forcing_recovery.html
InnoDB: about forcing recovery.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 73738 (LWP 30460)]
0x08223961 in ha_innobase::write_row(char*) (this=0x8a3fe08, record=0x8a3ff10 "?\021'") at ha_innodb.cc:2408
2408                    ut_a(prebuilt->trx->mysql_n_tables_locked == 2);
(gdb) bt
#0  0x08223961 in ha_innobase::write_row(char*) (this=0x8a3fe08, record=0x8a3ff10 "?\021'") at ha_innodb.cc:2408
#1  0x082338f7 in copy_data_between_tables (from=0x8a3cdd0, to=0x8a38c28, create=@0x8a5160c, handle_duplicates=DUP_ERROR, order_num=0, order=0x0, copied=0x0, deleted=0x0)
    at sql_table.cc:3434
#2  0x08232a04 in mysql_alter_table(THD*, char*, char*, st_ha_create_information*, st_table_list*, List<create_field>&, List<Key>&, unsigned, st_order*, enum_duplicates, st_alter_info*, bool) (thd=0x8a31ae0, new_db=0x8a3dc78 "crash_innodb", new_name=0x8a50bf0 "t0innodb", create_info=0x8a31fa8, table_list=0x8a50c28, fields=@0x0, keys=@0x8a31ed4, order_num=0, order=0x0, 
    handle_duplicates=DUP_ERROR, alter_info=0x8a320d8, do_send_ok=true) at sql_table.cc:3097
#3  0x08186d63 in mysql_execute_command(THD*) (thd=0x8a31ae0) at sql_parse.cc:2715
#4  0x0818b4e7 in mysql_parse(THD*, char*, unsigned) (thd=0x8a31ae0, inBuf=0x8a31b20 "\001", length=34) at sql_parse.cc:4588
#5  0x08183efb in dispatch_command(enum_server_command, THD*, char*, unsigned) (command=COM_QUERY, thd=0x8a31ae0, packet=0x8a48b39 "alter table t0innodb engine=innodb", packet_length=35)
    at sql_parse.cc:1503
#6  0x08183818 in do_command(THD*) (thd=0x8a31ae0) at sql_parse.cc:1311
#7  0x08182ca6 in handle_one_connection (arg=0x0) at sql_parse.cc:1047
#8  0x4002a941 in pthread_start_thread () from /lib/i686/libpthread.so.0
#9  0x4002aa45 in pthread_start_thread_event () from /lib/i686/libpthread.so.0
[19 Nov 2004 13:15] Sergey Petrunya
No need to send table data file, here is the complete test case in mysql-test language:

drop table if exists t0;
create table t0
(
  key1 int not null,
  index i1(key1)
);

--disable_query_log
insert into t0 values (1),(2),(3),(4),(5),(6),(7),(8);

let $1=16;
set @d=8;
while ($1)
{
  eval insert into t0 select key1+@d from t0;
  eval set @d=@d*2;
  dec $1;
}
--enable_query_log

alter table t0 add key2 int not null;
alter table t0 add key3 int not null;
update t0 set key2=key1,key3=key1;
alter table t0 add index i2(key2);
alter table t0 add primary key(key3);

flush tables;
alter table t0 engine=innodb;
[19 Nov 2004 13:38] Marko Mäkelä
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the original bug instead.

Thank you for your interest in MySQL.

Additional info:

See bug #6633.