[mythtv-users] channel confusion

Stephen Worthington stephen_agent at jsw.gen.nz
Mon Mar 8 02:54:14 UTC 2021

On Sun, 7 Mar 2021 11:53:49 -0800, you wrote:

>Thanks everyone for your responses.  Both the file system check on reboot
>and the check and repair of the database happen automatically, though I'm
>not sure if mythbackend knows or is forced to wait for the database repair
>to complete.  I use journaled file systems (ext4 and xfs) and so the
>filesystem check and repair process is a lot faster than it would otherwise

Have you done some special setup to cause the filesystems and database
to be fully checked automatically at boot?  If not, then it is not

What happens at boot time for the filesystems is that any partition
that is marked as dirty (having been written to but not shut down
properly) will have its journals processed.  This is *not* a
filesystem check.  It is *not* sufficient to prevent corruption,
although it does help quite a lot.

Some distros will also run fsck (once only) when they find a dirty
partition. However, if there have been any repairs done, fsck needs to
be run repeatedly until it reports there are no more problems.  I once
had to run fsck seven times on my mother's MythTV box boot partition
before it finally fixed all the problems caused by a power failure. So
one run of fsck done automatically will *not* prevent corruption,
although it certainly helps a lot.  This automatic fsck seems to be
dependent on the type of filesystem - it seems to be done on EXT
filesystems, but not some other types.  I do not know if it is done on
XFS (I use JFS for my recording drives).

For EXT filesystems, there is also a counter that counts down one
every boot and when it gets to zero, a filesystem check is done on
boot.  However, this is also *not* sufficient to prevent corruption,
as it only happens infrequently and when it happens, fsck is only run

For the database, if you have put optimize_mythdb in /etc/cron.daily,
as is recommended, that will be run daily at the time anacron is set
to run daily jobs.  Depending on how anacron is set up on your system,
daily jobs that have been missed will be run at boot time, so if your
PC is off at the time anacron normally runs (eg midnight or 07:00),
the daily jobs will be run shortly after boot time.  There are two
problems here: "shortly after" is a typically a few minutes, during
which time mythbackend may well start a recording and will write to
the database, potentially further corrupting it to the point where it
will be unrecoverable.  And if the boot time is after the time anacron
normally runs jobs, so the daily jobs have already been run that day,
depending on how anacron is set up, the daily jobs will not be run
shortly after boot but only many hours later at the next scheduled

Further, like fsck, if there is repair work done by optimize_mythdb,
it may seem to succeed, but a further check of the repaired table(s)
can show that there is still corruption present, requiring further

So, as I said, whenever you have a crash or bad shutdown, you need to
manually run full filesystem and database checks.

More information about the mythtv-users mailing list