[mythtv-users] REPAIR/OPTIMIZE in HouseKeeper

Tony Lill ajlill at ajlc.waterloo.on.ca
Fri Feb 23 17:07:01 UTC 2007


Yeechang Lee <ylee at pobox.com> writes:

> Greg Estabrooks <greg at phaze.org> says:
>> > solved decades ago.  Unfortunately, between MySQL's
>> > whole-table-locking
>> 
>> You can avoid this by using innodb instead of myisam as has been
>> mentioned before on this list.
>
> Huh. Would "whole-table locking" explain my issue 1) as I describe at
> <URL:http://www.gossamer-threads.com/lists/mythtv/users/247868#247868>?
> If so, how would I make the switch?

Probably. You know, it's not that hard to check with the backend to
see if it's busy and/or how long to the next recording. Here's couple
of scraps from my jumbo myth cron job that handles copying files
around and running mythfilldatabase and optimize and backup databases
and .... 

# policy 1 - run whenever nothing is writing
/bin/echo -e -n "GET / HTTP 1.0\r\nHost: 127.0.0.1:6544\r\n\r\n" | nc -w 5 localhost 6544 | grep "Encoder .* is local on .* and is recording" > /dev/null 2>&1
if [ $? -eq 0 ]; then 
    exit 0
fi

and this checks the time to next recording

sub TimeToNextShow {
  # Connect to the mythbackend status socket and read the time of the
  # next program to be recorded
  $port    = 6544;  # random port
  $iaddr   = inet_aton($host)               || die "no host: $host";
  $paddr   = sockaddr_in($port, $iaddr);
  
  $proto   = getprotobyname('tcp');
  socket(SOCK, PF_INET, SOCK_STREAM, $proto)  || die "socket: $!";
  connect(SOCK, $paddr)    || die "connect: $!";
  syswrite SOCK,"GET / HTTP 1.0\r\nHost: 127.0.0.1:6544\r\n\r\n";
  while (<SOCK>) {
    # If we're recording now, go away
    if( /Encoder \d+ is local on \w+ and is recording:/ ) {
      $end_time = time;
      print "Recording now, time to go: $_" if($verbose);
      exit 1;
    }
    
    # Grab the time of the first scheduled recording. Assume it is
    # within 24 hours, else there's something very wrong
    $am = "";
    if( ($nhour,$nmin,$am) = /<a href="#">\w+ \d+\/\d+ (\d+):(\d+) ([AP]M )?- / ) {
      # 12 am is 0, 12 pm is 12
      if( $nhour == 12 ) {
	$nhour = 0;
      }
      if( $am =~ /PM / ) {
	$nhour += 12;
      }
      # get rid of warnings
      $isdst = $yday = $sec = $wday = $mon = $year = $mday = 0;	
      ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
      if( $nhour < $hour ) {
	$nhour +=24;
      }
      $end_time = time + (($nhour - $hour)*60 + ($nmin - $min))*60;
      print "We have until ".scalar(localtime($end_time)). "\n" if ( $verbose );
      last;
    }
  }
  close (SOCK)            || die "close: $!";
  $end_time;
}


More information about the mythtv-users mailing list