Bug #33081 Falcon: crash and database corruption when altering indexed ucs2 column
Submitted: 8 Dec 2007 0:08 Modified: 16 Mar 2008 11:19
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Falcon storage engine Severity:S3 (Non-critical)
Version:6.0.5-alpha-debug OS:Linux (SUSE 10 64-bit)
Assigned to: Kevin Lewis CPU Architecture:Any

[8 Dec 2007 0:08] Peter Gulutzan
Description:
I create a Falcon table with a ucs2 column.
I create an index on the first character of the column.
I insert two rows.
I try to alter the column to VARBINARY.
Crash.

I restart mysqld and try to select from the table,
or use the database, or create another Falcon table
in another database.
Crash.

How to repeat:
mysql> create table hoo (s3 char(5) character set ucs2) engine=falcon;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into hoo (s3) values ('a!'),(null);
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> create index k on hoo(s3(1));
Query OK, 2 rows affected (0.02 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> alter table hoo modify column s3 varbinary(20);
ERROR 2013 (HY000): Lost connection to MySQL server during query
[8 Dec 2007 21:45] Kevin Lewis
I was able to reproduce this.  The engine hits and assert where the gopher thread is moving stuff from the serial log into the index page.  The two key values seem out of order.  The assert is at IndexRootPage::indexMerge(), line 1071;
	if (key.compare(&priorKey) > 0)
		//break;
		ASSERT(false);
[9 Dec 2007 4:05] MySQL Verification Team
Thank you for the bug report.

use test
create table hoo (s3 char(5) character set ucs2) engine=falcon;
insert into hoo (s3) values ('a!'),(null);
create index k on hoo(s3(1));
alter table hoo modify column s3 varbinary(20);

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 6.0.5-alpha-nt Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use test
Database changed
mysql> create table hoo (s3 char(5) character set ucs2) engine=falcon;
Query OK, 0 rows affected (0.28 sec)

mysql> insert into hoo (s3) values ('a!'),(null);
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> create index k on hoo(s3(1));
Query OK, 2 rows affected (0.28 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> alter table hoo modify column s3 varbinary(20);
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>

ntdll.dll!000000007754fdf0() 	
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]	
mysqld.exe!Error::error()  + 0x6f bytes	C++
mysqld.exe!Error::assertionFailed()  + 0x13 bytes	C++
mysqld.exe!IndexRootPage::indexMerge()  + 0xb04 bytes	C++
mysqld.exe!SRLUpdateIndex::commit()  + 0xc4 bytes	C++
mysqld.exe!SerialLogTransaction::commit()  + 0xe0 bytes	C++
mysqld.exe!SerialLogTransaction::doAction()  + 0x22 bytes	C++
mysqld.exe!Gopher::gopherThread()  + 0x138 bytes	C++
mysqld.exe!Thread::thread()  + 0x68 bytes	C++
mysqld.exe!Thread::thread()  + 0xe bytes	C++
kernel32.dll!000000007732cdcd() 	
ntdll.dll!000000007754c6e1()
[10 Dec 2007 11:58] 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/39641

ChangeSet@1.2748, 2007-12-10 11:58:37+01:00, hakank@lu0011.(none) +3 -0
  Added test case for Bug# 33081.
[10 Dec 2007 12:00] Hakan Küçükyılmaz
Added test case falcon_bug_33081.test and pushed into mysql-6.0-falcon-team tree.
[13 Dec 2007 0:50] Kevin Lewis
See this patch for a resolution to this assertion;
ChangeSet@1.2750, 2007-12-12 18:03:04-05:00, jas@rowvwade. +1 -0

The assert was only used to identify a situation in which the order of index entries in the serial log is different from what is expected.  Falcon will indert these entries into the index page correctly reguardless, so the patch is replaced by a debug log entry.

The core problem is not so serious, but is now tracked with bug#33190
[11 Feb 2008 19:57] Kevin Lewis
Patch is in mysql-6.0-falcon and mysql-6.0-release version 6.0.4
[12 Mar 2008 23:02] Bugs System
Pushed into 6.0.4-alpha
[16 Mar 2008 11:19] MC Brown
A note has been added to the 6.0.4 changelog: 

Using ALTER TABLE to convert a CHAR column using the ucs2 character set to VARBINARY when using a Falcon table would cause a crash.