Bug #31277 myisamchk --unpack corrupts a table
Submitted: 28 Sep 2007 14:11 Modified: 30 Nov 2007 16:12
Reporter: Shane Bester
Status: Closed
Category:Server: MyISAM Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: Sergey Vojtovich Target Version:5.0+
Tags: bfsm_2007_10_18, 5.0.48

[28 Sep 2007 14:11] Shane Bester
Description:
table is imported, compressed, and is fine.  after decompressing, it's corrupted:
mysql> source bck.txt
Query OK, 1 row affected (0.00 sec)

<cut 100+ lines>
Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

mysql> flush tables;
Query OK, 0 rows affected (0.00 sec)

E:\mysql-enterprise-gpl-5.0.48-win32\bin>myisampack ..\data\a\bck.MYI
Compressing ..\data\a\bck.MYD: (108 records)
- Calculating statistics
- Compressing file
6.046%
Remember to run myisamchk -rq on compressed tables

E:\mysql-enterprise-gpl-5.0.48-win32\bin>myisamchk -rq ..\data\a\bck.MYI
- check record delete-chain
- recovering (with sort) MyISAM-table '..\data\a\bck.MYI'
Data records: 108
- Fixing index 1

mysql> check table bck extended;
+-------+-------+----------+----------+
| Table | Op    | Msg_type | Msg_text |
+-------+-------+----------+----------+
| a.bck | check | status   | OK       |
+-------+-------+----------+----------+
1 row in set (0.00 sec)

mysql> flush tables;
Query OK, 0 rows affected (0.00 sec)

E:\mysql-enterprise-gpl-5.0.48-win32\bin>myisamchk --unpack ..\data\a\bck.MYI
- recovering (with sort) MyISAM-table '..\data\a\bck.MYI'
Data records: 108
- Fixing index 1

mysql> check table bck extended;
+-------+-------+----------+-----------------------------------------------+
| Table | Op    | Msg_type | Msg_text                                      |
+-------+-------+----------+-----------------------------------------------+
| a.bck | check | error    | Record at: 6704  Can't find key for index:  1 |
| a.bck | check | error    | Corrupt                                       |
+-------+-------+----------+-----------------------------------------------+
2 rows in set (0.00 sec)

mysql>

How to repeat:
see uploaded private data for the import.  table contained over 400 double type rows.
[30 Oct 2007 12:33] 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/36632

ChangeSet@1.2688, 2007-10-30 14:36:37+04:00, svoj@mysql.com +4 -0
  BUG#31277 - myisamchk --unpack corrupts a table
  
  With certain data sets (when compressed record length gets bigger than
  uncompressed) myisamchk --unpack may corrupt data file.
  
  Fixed that record length was wrongly restored from compressed table.
  
  No test case for this fix, as currently our test suite doesn't support
  execution of myisampack tool.
[7 Nov 2007 10:53] 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/37242

ChangeSet@1.2688, 2007-11-07 12:55:28+04:00, svoj@mysql.com +7 -0
  BUG#31277 - myisamchk --unpack corrupts a table
  
  With certain data sets (when compressed record length gets bigger than
  uncompressed) myisamchk --unpack may corrupt data file.
  
  Fixed that record length was wrongly restored from compressed table.
[23 Nov 2007 12:28] 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/38350

ChangeSet@1.2589, 2007-11-23 12:28:36+01:00, istruewing@stella.local +1 -0
  BUG#31277 - myisamchk --unpack corrupts a table
  Fixed a compiler warning on win64
[23 Nov 2007 12:52] 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/38354

ChangeSet@1.2589, 2007-11-23 12:52:29+01:00, istruewing@stella.local +1 -0
  BUG#31277 - myisamchk --unpack corrupts a table
  Fixed a compiler warning on win64. Backport from 5.1.
[28 Nov 2007 11:24] Bugs System
Pushed into 6.0.4-alpha
[28 Nov 2007 11:26] Bugs System
Pushed into 5.1.23-rc
[28 Nov 2007 11:27] Bugs System
Pushed into 5.0.54
[28 Nov 2007 11:47] Bugs System
Pushed into 4.1.24
[30 Nov 2007 2:20] Paul DuBois
Noted in 4.1.24, 5.0.54, 5.1.23, 6.0.4 changelogs.

myisamchk --unpack could corrupt a table.
[30 Nov 2007 8:10] Sergei Golubchik
Only a table with static (when unpacked) row format.
[30 Nov 2007 16:12] Paul DuBois
Corrected changelog entry:

myisamchk --unpack could corrupt a table that when unpacked has
static (fixed-length) row format.