Bug #24855 Crash mysqld 4.1.21 with corrupted tables
Submitted: 6 Dec 2006 15:17 Modified: 7 Feb 2007 12:19
Reporter: Riccardo Centi Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S1 (Critical)
Version:4.1.21, 4.1.23-BK OS:Windows (window, Linux)
Assigned to: Sergey Vojtovich CPU Architecture:Any
Tags: Crash SqlServer 4.1.21 with corrupted tables

[6 Dec 2006 15:17] Riccardo Centi
Description:
I have corrupted the frm and MYI mysql table files and then when I go to make a select query to this table the client returns no one error and generates a server crash. I have sent to you the corrupted table file and I hope that this mysql crash will be resolved.

How to repeat:
just select the table in the attachment
[6 Dec 2006 15:19] Riccardo Centi
Corrupted table

Attachment: sdasqldb.zip (application/x-zip-compressed, text), 1.88 KiB.

[6 Dec 2006 16:26] Valeriy Kravchuk
Thank you for a bug report. Verified just as described with your files uploaded and latest 4.1.23-BK on Linux:

openxs@suse:~/dbs/4.1> cp /tmp/datifiliale.* var/test4
openxs@suse:~/dbs/4.1> bin/mysqld_safe &
[1] 17078
openxs@suse:~/dbs/4.1> Starting mysqld daemon with databases from /home/openxs/d
bs/4.1/var

openxs@suse:~/dbs/4.1> 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 1 to server version: 4.1.23

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

mysql> use test4;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql>
Number of processes running now: 0
061206 17:39:04  mysqld restarted

mysql> select * from test4.datifiliale;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    1
Current database: test4

ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mys
ql.sock' (111)
ERROR:
Can't connect to the server

mysql>
Number of processes running now: 0
061206 17:39:15  mysqld restarted

mysql> exit
Bye

But the real problem is that myisamchk also crashes!

openxs@suse:~/dbs/4.1> bin/mysqladmin -uroot shutdown
STOPPING server from pid file /home/openxs/dbs/4.1/var/suse.pid
061206 17:39:27  mysqld ended

[1]+  Done                    bin/mysqld_safe
openxs@suse:~/dbs/4.1> cd var/test4
openxs@suse:~/dbs/4.1/var/test4> ls -l
total 28
-rwx------  1 openxs users 8609 2006-12-06 17:38 datifiliale.frm
-rwx------  1 openxs users  630 2006-12-06 17:38 datifiliale.MYD
-rwx------  1 openxs users 6144 2006-12-06 17:38 datifiliale.MYI
-rw-rw----  1 openxs users   65 2006-11-21 15:02 db.opt
openxs@suse:~/dbs/4.1/var/test4> ../../bin/myisamchk -e -r datifiliale.MYI
- recovering (with sort) MyISAM-table 'datifiliale.MYI'
Data records: 105
- Fixing index 1
Segmentation fault
[6 Dec 2006 16:38] Valeriy Kravchuk
Some details about the table:

openxs@suse:~/dbs/4.1/var/test4> ../../bin/myisamchk -d --verbose datifiliale.M
YI

MyISAM file:         datifiliale.MYI
Record format:       Fixed length
Character set:       latin1_swedish_ci (8)
File-version:        1
Creation time:       2006-12-06 17:43:54
Recover time:        2006-12-06 17:45:03
Status:              crashed
Data records:                    0  Deleted blocks:                 0
Datafile parts:                  0  Deleted data:                   0
Datafile pointer (bytes):        4  Keyfile pointer (bytes):        4
Datafile length:               630  Keyfile length:              1024
Max datafile length:   25769803774  Max keyfile length: 4398046510079
Recordlength:                    6

table description:
Key Start Len Index   Type                     Rec/key         Root  Blocksize
1   2     3   unique  char                           0                    1024
    5     2           varchar BLOB                   1
2   2     3   multip. char                           0                    1024
3   5     2   multip. varchar BLOB                   0                    1024
[6 Dec 2006 16:41] Valeriy Kravchuk
Riccardo,

Please, describe what you did to get a table like that? Any crashes, concurrent inserts, replication, myisamchk, backups at filesystem level, NFS, manual editing :) involved?
[11 Dec 2006 8:49] Riccardo Centi
1) The table was corrupted manually (with the use a notepad to simulate a corruption)
2) I repair with USE_FRM  and the first time I do it the operation go out without error and without crashes 
3) But when I go to select the table I have repaired then the server demon went in crash.
4) I try to repair again the table but the server crash before the repair table finished.
[12 Dec 2006 9:39] Riccardo Centi
I have manually corrupt some tables for reproducing some server crash we had in the server of our customers. It seems that sometime when the table is heavly corrupted the query made on this corrupted table instead of giving us an error  
makes the server going in crash , interrupting all services of our software.
[16 Jan 2007 14:03] 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/18187

ChangeSet@1.2590, 2007-01-16 18:05:37+04:00, svoj@mysql.com +1 -0
  BUG#24855 - Crash mysqld 4.1.21 with corrupted tables
  
  Accessing fixed record format table with crashed key definition results
  in server/myisamchk segmentation fault.
  
  This is fixed by refusing to open such tables. Affects MyISAM only.
  No test case, since it requires crashed table.
[25 Jan 2007 9:30] Sergey Vojtovich
Pushed to trees currently marked as 5.0.36 and 5.1.15.
[5 Feb 2007 11:42] Sergey Vojtovich
Pushed to tree currently marked as 4.1.23.
[7 Feb 2007 12:19] MC Brown
A note has been added to the 4.1.23, 5.0.36 and 5.1.15 changelogs.