My ongoing experiences with Ubuntu, and later Mythbuntu, as a media center with MythTV. I'm also using the system for a virtual machine server, a mediawiki server and a general all around home infrastructure base.

Saturday, March 7, 2009

Fixing MythTV Database: Table './mythconverg/credits' is marked as crashed

My MythTV box became unresponsive earlier this week, prompting a power cycle. It seemed to come back up OK, except a cron job was spitting out the following email every 10 minutes:
DBD::mysql::st execute failed: Table './mythconverg/credits' is marked as crashed and last (automatic?) repair failed at /usr/share/perl5/MythTV/
Program.pm line 195.
DBD::mysql::st fetchrow_array failed: fetch() without execute() at /usr/share/perl5/MythTV/Program.pm line 196.
I tried backing up the database manually and got a similar error:
#/etc/cron.weekly/mythtv-database
mythconverg.credits
warning : Table is marked as crashed and last repair failed
warning : 1 client is using or hasn't closed the table properly
error : Found 123809 keys of 124267
error : Corrupt
mysqldump: Got error: 144: Table './mythconverg/credits' is marked as crashed and last (automatic?) repair failed when using LOCK TABLES
Using google turned up the solution. But I didn't find the optimize_mythdb.pl script where the poster indicated. I did find it elsewhere, copied it over and set permissions on it:
# mkdir /usr/share/mythtv/contrib
# cp /usr/share/doc/mythtv-backend/contrib/optimize_mythdb.pl /usr/share/mythtv/contrib
# chmod 755 /usr/share/mythtv/contrib/optimize_mythdb.pl
At this point I was able to run the script as the poster indicated:
# /usr/share/mythtv/contrib/optimize_mythdb.pl
Repaired/Optimized: `mythconverg`.`archiveitems`
Analyzed: `mythconverg`.`archiveitems`
....snip...
Now the backup script ran cleanly:
# /etc/cron.weekly/mythtv-database
#
The last thing I did, as the comments in the optimize_mythdb.pl script suggest, was add the script to the daily anacron list (update March 15, 2009: anacron apparently doesn't run scripts with a .pl suffix, so need to link this to a filename without the suffix):
# ln -s /usr/share/mythtv/contrib/optimize_mythdb.pl /etc/cron.daily/optimize_mythdb
Post a Comment