Also on twitter ( twitter.com/nutrun )

Fixing corrupt WordPress MySQL tables

The blog was up and down today, and WordPress was complaining about low memory and database lookup failures. This is not a common situation on a nicely laid out Debian server and thankfully it wasn’t that difficult to fix either (3 minutes).

I did a massive apt-get update the other day, so I suspected it must’ve been something to do with that. A mysqladmin shutdown -p followed by a myisamchk --silent --force */*.MYI inside /var/lib/mysql revealed the problem – and promptly fixed it:

myisamchk: MyISAM file wordpress_db_dir/wp_sitemeta.MYI
myisamchk: warning: 1 client is using or hasn't closed the table properly
myisamchk: MyISAM file wordpress_db_dir/wp_comments.MYI
myisamchk: warning: 3 clients are using or haven't closed the table properly
myisamchk: MyISAM file wordpress_db_dir/wp_options.MYI
myisamchk: warning: 1 client is using or hasn't closed the table properly

That is not what bugs me, though. I think – although I don’t know – this might be a problem with WordPress, as I’ve had the exact same issue in the past and, again, it was WordPress tables that were causing it. Maybe I ought to start bringing down the site when upgrading, although I don’t want to miss out on my zero downtime Debian upgrades. Also, if you google “WordPress database error: [Out of memory” you get about 584,000 results. And boxes don’t run out of memory just like that…

I think the guys at WordPress need to look into handling server shutdowns more gracefully and a nice way of dealing with corrupt tables when that occurs which, by the looks of it, is quite often.

Comments are closed.