[MDEV-6245] Certain compressed tables with myisampack are corrupted by "CHECK TABLE" Created: 2014-05-16  Updated: 2014-05-17  Resolved: 2014-05-17

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 5.2.14, 5.3.12, 5.5.37, 10.0.11
Fix Version/s: 5.5.38, 10.0.12

Type: Bug Priority: Major
Reporter: Chris Calender (Inactive) Assignee: Michael Widenius
Resolution: Fixed Votes: 0
Labels: None
Environment:

Windows, Linux



 Description   

Creating a certain table and populating it with some dummy data, then compressing that table with myisampack, and then issuing a CHECK TABLE command results in corrupting the table (tested in MariaDB 5.5.37).

The same table and data does not get corrupted by CHECK TABLE in MySQL 5.5.37.

Here is a reproducible test case (I pared it down as far as I could for now):

create table `t1` (`id` varchar(15) DEFAULT NULL) ENGINE=MyISAM ROW_FORMAT=FIXED;
insert into t1 values ('aaa'),('bbb'),('ccc'),('ddd'),('eee');
insert into t1 (select * from t1);
insert into t1 (select * from t1);
insert into t1 (select * from t1);
insert into t1 (select * from t1);

..\..\bin\myisampack t1
..\..\bin\myisamchk -rq t1
..\..\bin\mysqladmin -uroot -pmysql -P3314 flush-tables

check table t1;
# <-- corrupt!

mysql> check table t1;
+-----------+-------+----------+-----------------------------------------------------------------------+
| Table     | Op    | Msg_type | Msg_text                                                              |
+-----------+-------+----------+-----------------------------------------------------------------------+
| packed.t1 | check | warning  | Record checksum is not the same as checksum stored in the index file  |
| packed.t1 | check | error    | Corrupt                                                               |
+-----------+-------+----------+-----------------------------------------------------------------------+
 
mysql> check table t1;
+-----------+-------+----------+-----------------------------------------------------------------------+
| Table     | Op    | Msg_type | Msg_text                                                              |
+-----------+-------+----------+-----------------------------------------------------------------------+
| packed.t1 | check | warning  | Table is marked as crashed                                            |
| packed.t1 | check | warning  | Record checksum is not the same as checksum stored in the index file  |
| packed.t1 | check | error    | Corrupt                                                               |
+-----------+-------+----------+-----------------------------------------------------------------------+

I suspect the varchar and the row_format=fixed are involved somehow.



 Comments   
Comment by Elena Stepanova [ 2014-05-16 ]

I can reproduce it on the top of 5.5 tree (revno 4189), but only on a non-debug build (I built with cmake . && make).

MTR test case:

create table `t1` (`id` varchar(15) DEFAULT NULL) ENGINE=MyISAM ROW_FORMAT=FIXED;
insert into t1 values ('aaa'),('bbb'),('ccc'),('ddd'),('eee');
insert into t1 (select * from t1);
insert into t1 (select * from t1);
insert into t1 (select * from t1);
insert into t1 (select * from t1);
FLUSH TABLES;
 
let $MYSQLD_DATADIR= `select @@datadir`;
--disable_abort_on_error
--exec $MYISAMPACK $MYSQLD_DATADIR/test/t1
--exec $MYISAMCHK -rq $MYSQLD_DATADIR/test/t1
--exec $MYSQLADMIN flush-tables
--enable_abort_on_error
 
CHECK TABLE t1;

Please note that disable/enable abort can be removed, but then the test case will fail not on CHECK TABLE, but on myisamchk.

Comment by Michael Widenius [ 2014-05-17 ]

I was able to repeat this in the latest 5.5 MariaDB version.
The issue was a bug in the way we try to keep MyISAM compatible with MySQL when there is no calculated checksum for the table.
This bug affected compressed tables with fixed row length and NULL fields.
The table was usable, but check table gave an error that it had the wrong checksum. After running check table, one could still access the table, but one would get a warning that the table was corrupted.

This is now fixed and pushed into 5.5i

Comment by Michael Widenius [ 2014-05-17 ]

Fixed and pushed

Generated at Thu Feb 08 07:10:26 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.