Bug #53591 crash with fast alter table and text/blob prefix primary key
Submitted: 12 May 2010 6:46 Modified: 14 Oct 2010 15:18
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB Plugin storage engine Severity:S1 (Critical)
Version:plugin 1.0.7, 5.1.46, 5.5.x OS:Any
Assigned to: Marko Mäkelä CPU Architecture:Any

[12 May 2010 6:46] Shane Bester
Description:
crash when trying to add primary key which is prefix of a text/blob
and using fast alter table with small key_block_size:

Version: '5.1.46-enterprise-gpl-advanced'  socket: ''  port: 3306  MySQL Enterprise Server - Advanced Edition (GPL)
100512  8:44:14  InnoDB: Assertion failure in thread 2272 in file .\que\que0que.c line 1410
InnoDB: Failing assertion: trx->error_state == DB_SUCCESS

ha_innodb_plugin.dll!que_eval_sql()[que0que.c:1410]
ha_innodb_plugin.dll!row_drop_table_for_mysql()[row0mysql.c:3256]
ha_innodb_plugin.dll!row_merge_drop_table()[row0merge.c:2476]
ha_innodb_plugin.dll!ha_innodb::add_index()[handler0alter.cc:895]
mysqld.exe!mysql_alter_table()[sql_table.cc:7277]
mysqld.exe!mysql_execute_command()[sql_parse.cc:2902]
mysqld.exe!mysql_parse()[sql_parse.cc:5975]
mysqld.exe!dispatch_command()[sql_parse.cc:1235]
mysqld.exe!do_command()[sql_parse.cc:878]
mysqld.exe!handle_one_connection()[sql_connect.cc:1127]
mysqld.exe!pthread_start()[my_winthread.c:85]
mysqld.exe!_callthreadstart()[thread.c:293]

How to repeat:
#start server with innodb plugin options:
#--innodb_file_per_table --innodb-file-format=barracuda

set old_alter_table=0;
drop table if exists `t5`;
create table `t5`(`a` text charset utf8 not null)
engine=innodb key_block_size=1;
alter table `t5` add primary key(`a`(220));
[12 May 2010 6:50] MySQL Verification Team
oops, trx->error_state=0x22 (DB_TOO_BIG_RECORD)
[12 May 2010 7:11] Valeriy Kravchuk
Thank you for the bug report. Verified just as described, also - with 5.5.x. Stack trace is similar:

 	mysqld.exe!que_eval_sql(pars_info_struct * info=0x051547d8, const char * sql=0x007e3d78, unsigned long reserve_dict_mutex=0, trx_struct * trx=0x05192380)  Line 1410 + 0x3d bytes	
 	mysqld.exe!row_drop_table_for_mysql(const char * name=0x051545b8, trx_struct * trx=0x05192380, unsigned long drop_db=0)  Line 3256 + 0xe bytes	
 	mysqld.exe!row_merge_drop_table(trx_struct * trx=0x05192380, dict_table_struct * table=0x051544f8)  Line 2441 + 0x10 bytes	
 	mysqld.exe!ha_innobase::add_index(TABLE * table=0x0519f930, st_key * key_info=0x00000001, unsigned int num_of_keys=85224328)  Line 887 + 0x7 bytes	
 	mysqld.exe!mysql_alter_table(THD * thd=0x0108c868, char * new_db=0x0519b068, char * new_name=0x00000000, st_ha_create_information * create_info=0x05a0e3e8, TABLE_LIST * table_list=0x0519acd0, Alter_info * alter_info=0x05a0e4d0, unsigned int order_num=0, st_order * order=0x00000000, bool ignore=false)  Line 7247 + 0x1c bytes	
 	mysqld.exe!mysql_execute_command(THD * thd=0x0108c868)  Line 2782 + 0x4b bytes	
 	mysqld.exe!mysql_parse(THD * thd=0x0108c868, const char * inBuf=0x0519ac00, unsigned int length=42, const char * * found_semicolon=0x05a0f63c)  Line 5735 + 0x6 bytes	
 	mysqld.exe!dispatch_command(enum_server_command command=COM_QUERY, THD * thd=0x0108c868, char * packet=0x05192929, unsigned int packet_length=42)  Line 1026	
 	mysqld.exe!do_command(THD * thd=0x00000003)  Line 710 + 0xf bytes	
 	mysqld.exe!do_handle_one_connection(THD * thd_arg=0x0108c868)  Line 1174 + 0xa bytes	
 	mysqld.exe!handle_one_connection(void * arg=0x0108c868)  Line 1113 + 0x6 bytes	
 	mysqld.exe!pthread_start(void * p=0x051023c8)  Line 61 + 0x3 bytes	
>	mysqld.exe!_callthreadstartex()  Line 348 + 0x6 bytes	
 	mysqld.exe!_threadstartex(void * ptd=0x05196938)  Line 326 + 0x5 bytes	
 	kernel32.dll!7c80b729()
[12 May 2010 9:15] Marko Mäkelä
Looks like a bug in error handling, an assertion when dropping the table.
[12 May 2010 10:42] Marko Mäkelä
For the documentation: The error handler of fast CREATE INDEX forgot to reset the error state of the transaction before attempting to undo the failed operation.
[12 May 2010 10:42] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/108100
[12 May 2010 10:42] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/108101
[12 May 2010 10:44] Jimmy Yang
Ok to Push
[12 May 2010 10:46] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/108103
[12 May 2010 10:46] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/108104
[31 May 2010 8:28] Bugs System
Pushed into 5.1.48 (revid:vasil.dimov@oracle.com-20100531082307-9x08gg1g7zybx2jy) (version source revid:vasil.dimov@oracle.com-20100513074652-0cvlhgkesgbb2bfh) (merge vers: 5.5.5-m3) (pib:16)
[17 Jun 2010 6:13] Bugs System
Pushed into 5.5.5-m3 (revid:alexey.kopytov@sun.com-20100615145247-8bj0vmuqlotbqsn9) (version source revid:marko.makela@oracle.com-20100512104212-e2h9n1obxjb8tfg4) (merge vers: 5.1.48) (pib:16)
[17 Jun 2010 6:17] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100615150216-cubqoyn1fj9b6a2p) (version source revid:marko.makela@oracle.com-20100512104212-e2h9n1obxjb8tfg4) (pib:16)
[18 Jun 2010 0:15] Paul DuBois
Noted in 5.1.48, 5.5.5 changelogs.

For InnoDB tables, the error handler for a fast CREATE INDEX did not
reset the error state of the transaction before attempting to undo a
failed operation, resulting in a crash.
[14 Oct 2010 8:37] Bugs System
Pushed into mysql-5.1-telco-7.0 5.1.51-ndb-7.0.20 (revid:martin.skold@mysql.com-20101014082627-jrmy9xbfbtrebw3c) (version source revid:vasil.dimov@oracle.com-20100513074652-0cvlhgkesgbb2bfh) (merge vers: 5.5.5-m3) (pib:21)
[14 Oct 2010 8:53] Bugs System
Pushed into mysql-5.1-telco-6.3 5.1.51-ndb-6.3.39 (revid:martin.skold@mysql.com-20101014083757-5qo48b86d69zjvzj) (version source revid:vasil.dimov@oracle.com-20100513074652-0cvlhgkesgbb2bfh) (merge vers: 5.5.5-m3) (pib:21)
[14 Oct 2010 9:08] Bugs System
Pushed into mysql-5.1-telco-6.2 5.1.51-ndb-6.2.19 (revid:martin.skold@mysql.com-20101014084420-y54ecj85j5we27oa) (version source revid:vasil.dimov@oracle.com-20100513074652-0cvlhgkesgbb2bfh) (merge vers: 5.5.5-m3) (pib:21)
[14 Oct 2010 15:18] Jon Stephens
Already documented in the 5.1.48 changelog; no new changelog entries required. setting back to Closed state.