[mythtv-users] Repair mysql tables after power failure?
R. G. Newbury
newbury at mandamus.org
Wed Oct 3 19:13:54 UTC 2007
Mike Perkins wrote:
> David Brodbeck wrote:
>> On Oct 3, 2007, at 6:51 AM, Mike Perkins wrote:
>>> Hmmm. Note to self: add this to startup on the master backend, in
>>> such a way it
>>> runs before the backend starts. The master backend machine
>>> currently stays up
>>> forever, unless there's a power outage. Although I run a script
>>> containing this
>>> around 02:00 every night, I hadn't considered possible corruption
>>> after a power
>>> cut/restart. Filesystems get checked on startup, why not databases?
>>>
>>> In fact, does Mysql do anything useful on startup in this regard?
>> I don't think it does by default. Some distributions include a table
>> check in their startup script. I like to add one, for the reasons
>> you state.
>>
>> If you want to get really fancy, create a file in the startup script
>> and delete it in the shutdown script, then only do the check on
>> startup if the file is present. This would mimic the way fsck will
>> only check "dirty" filesystems.
>>
> Consider it done. Is it worth adding something of this kind to Mythtv startup
> generally? OK, I get a couple of outages/year so it's not a big problem
> (actually, night before last, had 5 in 15 minutes, which is why this is in the
> front of my brain just now). But power outages aren't the only reason a backend
> can fall over. Should we be considering a database check every time the backend
> comes up, if the above-mentioned "dirty" flag exists? i.e. built in to the
> backend startup and shutdown scripts?
>
> Mike Perkins
Yes, please! I was thinking about this over lunch and it occurs to me
that a standalone optimize/check script which could be run be the
start/stop service scripts would also work as a cron script, with a
little care. Among other things, it should note the presence of the
'dirty-bit' flag and restore that state, if run from a cron.
Hmm, on second thought, it should ignore the present state, and *set*
the flag, immediately on entry, whether as startup or as a cron job, in
case it fails, or the power cycles, while it is running.
Then the start script needs only a one-line call to the script, while
shutdown is a one-line 'rm -f...'
R. Geoffrey Newbury
Tux says: "Be regular. Eat cron flakes."
More information about the mythtv-users
mailing list