Bug #53646 myisampack corrupts tables with fulltext indexes
Submitted: 14 May 2010 13:27 Modified: 29 Sep 2011 12:59
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S1 (Critical)
Version:5.0.90, 5.1.46, 5.1.48-bzr, 5.5.4 OS:Any
Assigned to: CPU Architecture:Any
Tags: compressed, corruption, fulltext, myisampack

[14 May 2010 13:27] Shane Bester
Description:
after packing myisam table, i got a corruption:

1. PACK:
Compressing ..\data\test\t13.MYD: (2 records)
- Calculating statistics
- Compressing file
96.54%
Remember to run myisamchk -rq on compressed tables

2. REPAIR:
- check record delete-chain
- recovering (with sort) MyISAM-table '..\data\test\t13.MYI'
Data records: 2
- Fixing index 1

3. CHECK:
Checking MyISAM file: ..\data\test\t13.MYI
Data records:       2   Deleted blocks:       0
- check file-size
- check record delete-chain
- check key delete-chain
- check index reference
- check data record references index: 1
myisamchk: error: Key in wrong position at page 1024
- check record links
myisamchk: error: Keypointers and record positions doesn't match
MyISAM-table '..\data\test\t13.MYI' is corrupted
Fix it using switch "-r" or "-o"

How to repeat:
drop table if exists `t13`;
create table `t13` (`col31` char(255),fulltext key (`col31`)
) engine=myisam default charset=utf8;
insert into `t13` values ('aaaaaa'),('bbbbbb');

#shutdown server and pack the table:

myisampack t13.MYI
myisamchk -rq t13.MYI
myisamchk -vv t13.MYI
[14 May 2010 13:52] Valeriy Kravchuk
Verified just as described on Mac OS X:

valeriy-kravchuks-macbook-pro:5.1 openxs$ bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.1.48-debug Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> drop table if exists `t13`;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> create table `t13` (`col31` char(255),fulltext key (`col31`)
    -> ) engine=myisam default charset=utf8;
Query OK, 0 rows affected (0.08 sec)

mysql> insert into `t13` values ('aaaaaa'),('bbbbbb');
Query OK, 2 rows affected (0.03 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> exit
Bye
valeriy-kravchuks-macbook-pro:5.1 openxs$ bin/mysqladmin -uroot shutdown
100514 16:49:50 mysqld_safe mysqld from pid file /Users/openxs/dbs/5.1/var/77-52-5-191.dialup.umc.net.ua.pid ended
[1]+  Done                    bin/mysqld_safe
valeriy-kravchuks-macbook-pro:5.1 openxs$ cd var/test
valeriy-kravchuks-macbook-pro:test openxs$ ../../bin/myisampack t13.MYI
Compressing t13.MYD: (2 records)
- Calculating statistics
- Compressing file
96.54%     
Remember to run myisamchk -rq on compressed tables
valeriy-kravchuks-macbook-pro:test openxs$ ../../bin/myisamchk -rq t13.MYI
- check record delete-chain
- recovering (with sort) MyISAM-table 't13.MYI'
Data records: 2
- Fixing index 1
valeriy-kravchuks-macbook-pro:test openxs$ ../../bin/myisamchk -vv t13.MYI
Checking MyISAM file: t13.MYI
Data records:       2   Deleted blocks:       0
- check file-size
- check record delete-chain
No recordlinks
- check key delete-chain
block_size 1024:
- check index reference
- check data record references index: 1
myisamchk: error: Invalid key block position: 42405  key block size: 1024  file_length: 2048
- check record links
myisamchk: error: Keypointers and record positions doesn't match
MyISAM-table 't13.MYI' is corrupted
Fix it using switch "-r" or "-o"
[29 Sep 2011 12:59] Paul DuBois
Noted in 5.1.60, 5.5.17, 5.6.4 changelogs.

myisampack could create corrupt FULLTEXT indexes when compressing
tables.