Fixing Crashed MySQL Tables

Note: the gremlins came back today. The sessions table had mushroomed in size. I had to repair it before I could empty it but life seems better now.

 

I found one of the web servers unresponsive on Wednesday morning. Worse, the router between my workstation and the web server was gasping. In a rash attempt to improve life on the router, I thoroughly trashed it. But that is another story.

A visit to the NOC confirmed the router was just a herring in the kettle and after banging off the wrong server, I finally bounced the web server I was trying to reach. It came back up without complaint but I have been running into error messages like this:

Warning: Table './downtown/sessions' is marked as crashed and should be repaired query: SELECT u.*, s.* FROM users u INNER JOIN sessions s ON u.uid = s.uid WHERE s.sid = 'c77834b830ccb47e38d2943454aba057' in /home/lsnet/public_html/downtowngalax.com/includes/database.mysql.inc on line 128

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/lsnet/public_html/downtowngalax.com/includes/database.mysql.inc:128) in /home/lsnet/public_html/downtowngalax.com/includes/bootstrap.inc on line 1031

Warning: Table './downtown/variable' is marked as crashed and should be repaired query: SELECT * FROM variable in /home/lsnet/public_html/downtowngalax.com/includes/database.mysql.inc on line 128

Warning: Cannot modify header information - headers already sent by (output started at /home/lsnet/public_html/downtowngalax.com/includes/database.mysql.inc:128) in /home/lsnet/public_html/downtowngalax.com/includes/bootstrap.inc on line 630

Warning: Cannot modify header information - headers already sent by (output started at /home/lsnet/public_html/downtowngalax.com/includes/database.mysql.inc:128) in /home/lsnet/public_html/downtowngalax.com/includes/bootstrap.inc on line 631

Warning: Cannot modify header information - headers already sent by (output started at /home/lsnet/public_html/downtowngalax.com/includes/database.mysql.inc:128) in /home/lsnet/public_html/downtowngalax.com/includes/bootstrap.inc on line 632

Warning: Cannot modify header information - headers already sent by (output started at /home/lsnet/public_html/downtowngalax.com/includes/database.mysql.inc:128) in /home/lsnet/public_html/downtowngalax.com/includes/bootstrap.inc on line 633

MySQL has multiple storage engines but I am using ISAM for this database and the recovery method is straightforward. The crashed files are owned by "mysql" (not me) so I need "root" access. If I were an "ordinary" user on a shared hosting server, my only recourse would be to contact my "sysadmin" who would have to perform the following:

root@galax:/var/lib/mysql/drupal# myisamchk -r sessions
root@galax:/var/lib/mysql/drupal# myisamchk -r variable

There may be others so the prudent (and reasonably safe) move is to:

root@galax:/var/lib/mysql/drupal# myisamchk -r *.MYI

If you are one of our web customers, you should not be able to do this (there would have to be a rotten herring in the kettle). Use the contact form or leave a voice mail message.