Bug #22660 MySql reports table corruption but does not repair it
Submitted: 25 Sep 2006 9:58 Modified: 26 Sep 2006 6:52
Reporter: Sergei Kulakov (Candidate Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:All OS:
Assigned to: CPU Architecture:Any
Tags: Select / Repair Table

[25 Sep 2006 9:58] Sergei Kulakov
Description:
When some tables are corrupted MySql returns errors like "Got error ### from table handler" (1030) or "Can't open file: table.MYI" etc. Then you have to check and repair the table. Can MySql do it automatically? When it knows the table is corrupted anyway it could fix it right away, currently the problem will remain until you get down to it, it may last for days / weeks. 

How to repeat:
Get a broken table (remove the index file), run a select on the table and you will get the error 

Can't open file: table.MYI

No matter how many times you will run the query the error will remanin the same. 

Suggested fix:
Check some error codes (like 1016, 1017, 1022, 1030, 1032, 1033, 1034, 1035) and then automaticalluy check and fix (repair) the table. Which options to use for the commands check and repair depends on the error. 

The advantage is that MySql knows which table(s) to fix, while the user only knows that there is some table broken but they don't know which (for errors like "Got error ### from table handler"). This way MySql can only check the table in question, not all of them. Also, MySql can select the right options for checking / repairing. 

This behavoiur can be optional of course. 

For now one has to implement custom checks for error codes and table checking / repairing functions. That is when a query returns one of the errorcodes above you have to check tables and repair them if they are broken.
[25 Sep 2006 10:17] Valeriy Kravchuk
Thank you for a feature request. Isn't --myisam-recover option (see http://dev.mysql.com/doc/refman/5.0/en/server-options.html) enough for most cases when table can be repaired automatically?
[25 Sep 2006 11:05] Sergei Kulakov
My fault, I missed it. This is not a bug, you can delete it.
[26 Sep 2006 6:52] Valeriy Kravchuk
Closed as we have a feature similar to requested.