Bug #29207 archive table reported as corrupt by check table
Submitted: 19 Jun 2007 12:16 Modified: 7 Jul 2007 18:52
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Archive storage engine Severity:S1 (Critical)
Version:5.0.44BK OS:Any
Assigned to: Sergey Vojtovich CPU Architecture:Any
Tags: archive, corruption

[19 Jun 2007 12:16] Shane Bester
Description:
archive tables get corrupted:

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

mysql> create table t1(a longblob)engine=archive;
Query OK, 0 rows affected (0.08 sec)

mysql> insert into t1 set a=0xECB9957D36C2B82A69DDA52C3056;
Query OK, 1 row affected (0.03 sec)

mysql> insert into t1 set a=0x47CDA6CA85CDA44AC789E68389E19A95ECB190DBA4E3B39BEA9BB9DA92E182A
Query OK, 1 row affected (0.00 sec)

mysql> check table t1 extended;
+---------+-------+----------+----------+
| Table   | Op    | Msg_type | Msg_text |
+---------+-------+----------+----------+
| test.t1 | check | error    | Corrupt  |
+---------+-------+----------+----------+
1 row in set (0.02 sec)

mysql> repair table t1;
+---------+--------+----------+----------+
| Table   | Op     | Msg_type | Msg_text |
+---------+--------+----------+----------+
| test.t1 | repair | status   | OK       |
+---------+--------+----------+----------+
1 row in set, 2 warnings (0.06 sec)

mysql> show warnings;
+-------+------+--------------------------------------------------------------------------+
| Level | Code | Message                                                                  |
+-------+------+--------------------------------------------------------------------------+
| Error |    5 | Out of memory at line 51, 'sql_string.cc'                                |
| Error |    5 | needed -1515870808 byte (2713962k), memory in use: 8678458 bytes (8476k) |
+-------+------+--------------------------------------------------------------------------+
2 rows in set (0.00 sec)

How to repeat:
drop table if exists t1;
create table t1(a longblob)engine=archive;
insert into t1 set a=0xECB9957D36C2B82A69DDA52C3056;
insert into t1 set a=0x47CDA6CA85CDA44AC789E68389E19A95ECB190DBA4E3B39BEA9BB9DA92E182AA7067E69C8005E58980344A2DE890B8DA803D06E5BCA461E99AA0E0928428E982801D0BE3B7A43D437AE3859E4BD9945CC2955956E3B6A853C18713E5A7B636E3808D205B3C167E25EE96BC01745B6EE980B4156BCB8059CAA7E8B4893971E9828EEC9E9C31;
check table t1 extended;
repair table t1;

Suggested fix:
.
[19 Jun 2007 12:18] Shane Bester
the above insert statements must be one line each!! cut'n'paste might not work.
[19 Jun 2007 12:19] Shane Bester
testcase in a file so bugs system doesn't wrap it.

Attachment: bug29207_testcase.txt (text/plain), 476 bytes.

[19 Jun 2007 12:20] Shane Bester
can cause server to overallocate memory.  upping the severity.
070619 14:18:11 [ERROR] mysqld-debug: Out of memory at line 51, '.\sql_string.cpp'
070619 14:18:11 [ERROR] mysqld-debug: needed -1515870808 byte (2713962k), memory in use: 9206422 bytes (8991k)
[19 Jun 2007 12:36] Shane Bester
another testcase

Attachment: bug29207_testcase_2.txt (text/plain), 511 bytes.

[19 Jun 2007 12:45] Shane Bester
----------
better testcase
----------

drop table if exists t1;
create table t1(a longblob)engine=archive;
insert into t1 set a=repeat('a',0);
insert into t1 set a=repeat('a',1);
check table t1 extended;
[27 Jun 2007 9:17] 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/29683

ChangeSet@1.2493, 2007-06-27 13:19:34+05:00, svoj@mysql.com +3 -0
  BUG#29207 - archive table reported as corrupt by check table (P1)
  
  CHECK TABLE against ARCHIVE table may falsely report table corruption,
  or cause server crash.
  
  Fixed by using proper buffer for CHECK TABLE.
  
  Affects both 5.0 and 5.1.
[27 Jun 2007 16:22] Brian Aker
This looks fine... but I am thinking the code was originally this way, and was later changed for some reason...  but looks good.
[27 Jun 2007 16:22] Brian Aker
This looks fine... but I am thinking the code was originally this way, and was later changed for some reason...  but looks good.
[28 Jun 2007 10:02] 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/29835

ChangeSet@1.2522, 2007-06-28 14:04:20+05:00, svoj@mysql.com +1 -0
  BUG#29207 - archive table reported as corrupt by check table
  After merge fix.
[7 Jul 2007 16:34] Bugs System
Pushed into 5.1.21-beta
[7 Jul 2007 16:36] Bugs System
Pushed into 5.0.46
[7 Jul 2007 18:52] Paul Dubois
Noted in 5.0.46, 5.1.21 changelogs.

CHECK TABLE for ARCHIVE tables could falsely report table corruption
or cause a server crash.