[mythtv-users] Must mythbackend be running when executing optimize_mythdb.pl and/or mythlink.pl?

Michael T. Dean mtdean at thirdcontact.com
Sat Apr 7 14:42:17 UTC 2012


On 04/06/2012 09:20 PM, James Linder wrote:
> On 07/04/2012, at 6:35 AM, Michael T. Dean wrote:
>
> [snip]
>
>> Also, the only reason we don't automatically run optimize_mythdb.pl type
>> functionality (repair/analyze/optimize)--we already have code in MythTV
>> to do it all--is because if it were being run and the MySQL server
>> crashes (mysqld crash/power outage/full file system/...) during a table
>> repair, it's critical that a repair is run, again, after restarting the
>> server and before any client attempts to read any data from the table
>> that was being repaired--otherwise, you could lose all of the data in
>> the table.  Therefore, since we can't guarantee that we'll be able to
>> run the repair before anyone else reads from the table before, and
>> because even doing a quick check to see if tables are good before
>> starting the master backend slowed startup sufficiently, on some
>> systems, that we had to remove the check.  That means
>> repair/analyze/optimize are left to the user/"db admin" for the system.
>> And, if there's a database crash, you should probably shut down all
>> MythTV applications, then do an optimize_mythdb.pl or mysqlcheck -r
>> before restarting MythTV (really, that's a good idea any time there's a
>> MySQL crash, even if you weren't running a repair at the time).
>> (Unfortunately, currently optmize_mythdb.pl requires a working settings
>> table, so if your settings table is crashed, you'll need to run
>> mysqlcheck -r directly--and figure out all the right command-line
>> arguments.  I'm hoping to fix that, sometime.)
> OK the proverbial dumb question:
>
> I've been using myth for *years* and have never run optimize_mythdb.pl !!
>
> Dutifully I tried:
> [sandypit] /home/jam/mythtv-0.24.2/contrib [68]% maintenance/optimize_mythdb.pl
> Can't locate MythTV.pm in @INC
>
> and cpan search showed nothing
> (but there are a couple of candidates in the directory)
>
> so
>
> why would I run optimize_mythdb.pl ( know that is a kick-me question :-) )
> Where would I put MythTV,pm ?
>
> [sandypit] /home/jam/mythtv-0.24.2/contrib [71]% ls /usr/lib/perl5/
> 5.14.2/  site_perl/  vendor_perl/
>

In theory/ideally, you'd never have to run optimize_mythdb.pl.  The 
primary benefit it provides is that it runs a check of your tables and 
repairs any crashed tables.  Tables generally crash when MySQL isn't 
shut down properly or when the file system containing MySQL data is 
filled (meaning MySQL can't write new data).  Running optimize_mythdb.pl 
in a daily cron job is just a way of ensuring that you'll lose less than 
one day's worth of recordings should your system, for example, shut down 
other-than-nicely and reboot itself--such that you may not realize that 
a table is crashed (or may not be around to notice).  Or, it will do a 
repair if you forget to repair after fixing an underlying problem (such 
as fixing the full file system issue or restarting a killed MySQL 
process).  Optimize and analyze are also performed, but have very little 
effect on a proper MythTV database (though may actually improve 
efficiency on tables that were created on other versions of MythTV and 
upgraded rather than backed up and restored).

As for MythTV.pm, that is one of the MythTV Perl bindings 
files--optimize_mythdb.pl requires the Perl bindings--that's installed 
when installing (core) MythTV.  Note, though, that Perl bindings won't 
be installed if you don't have required prerequisite modules, and 
configure will tell you what's missing (so check your configure 
output).  Packagers may put the bindings in a separate package, so if 
you're using packages, you'd have to ask users of your distro/packages 
how to get the Perl bindings on your system.

Mike


More information about the mythtv-users mailing list