Search code examples
mysqlruby-on-railsmysql-error-1064

Mysql::Error: Table 'table_name' is marked as crashed and should be repaired


I have this error "Mysql::Error: Table 'table_name' is marked as crashed and should be repaired" that is repeated several times,

I know how I solve this problem : to run this from my server's command line: mysqlcheck --repair --all-databases..

but I do not know the cause!!

Notes: I develop with ruby on rails and i'm using mysql 5.1.49, table type: MyISAM, table size : between 50 Mo and 500 Mo Also there are multi-insert on this tables.

I thought about making a script that repairs the table every night, but i see that this is a bad idea.

My question: is there any configuration to apply on mysql or do you suspect that there is a problem in the code? In fact, every time there is this error, i have to launch the command to repair this table.

Thanks


Solution

  • Application code shouldn't be able to crash a mysql table, whatever it does. This error points to an error in mysql itself; running out of disk space is the most likely, but other causes could be a hardware fault, other processes trying to manipulate the mysql files at the same time as mysql, or even a bug in mysql.

    You might check the mysql error log and the output of CHECK TABLE on your crashed table next time you have the problem.