<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi there,<br>
<br>
I've delved into the code and think I've figured out why the machine is
shutting down when it shouldn't.&nbsp; It's not while the job is running ...
but after a job completes and before the next starts. And would
appreciate one of the developers opinions on how to fix this (so have
CCed dev).<br>
<br>
If I understand the idle detection / shutdown process .... I think it
is slightly flawed.&nbsp; Here's how I think it works.<br>
<ol>
  <li>The scheduler (scheduler.cpp), detects that there are no
recordings in progress, and no clients detected so starts the idle
count down.</li>
  <li>Once the idle timeout is reached, the CheckShutdownServer()
method is called.&nbsp; By default this calls "mythshutdown --check", which
checks various things to see if the shutdown is allowed.&nbsp; One thing is
it does is to grep the list of running programs to see if
"mythtranscode" or "mythcommflag" are running.&nbsp; If "mythshutdown
--check" indicates that the shutdown cannot happen, the idle idle time
is reset, and the process starts again.</li>
  <li>This happens over and over.&nbsp; In the logs you see the the idles
countdown, counting down to 0..... than starting over again.<br>
  </li>
</ol>
<br>
The problem arises when the "CheckShutdownServer()" is called just
after a job has completed, and the next job has not yet started.&nbsp; This
will cause the machine to be shutdown even though there are still jobs
pending in the queue.<br>
<br>
Possible work-arounds are:<br>
<ul>
  <li>Increase the idle timeout.&nbsp; This will mean that "CheckShutdownServer()"
is called less often, which will reduce the likelihood of incorrect
shutdown.</li>
  <li>Reduce the "JobQueueCheckFrequency" from the default of 60
seconds.&nbsp;&nbsp; This will reduce the time between one job completing and the
next job starting, which will reduce the likelihood of incorrect
shutdown.</li>
</ul>
These are OK options.&nbsp; But neither is perfect.&nbsp;&nbsp; I'd like to keep the
idle shutdown time short, so the machine shuts down soon after becoming
idle.&nbsp;&nbsp; Setting the job check frequency too low will cause unnecessary
work checking the job queue when it rarely changes state.<br>
<br>
Any ideas on the best way to improve this behaviour?&nbsp; One thought I had
was to perform the "CheckShutdownServer()", more often than just once
that idle timeout has expired.&nbsp; Say once every 10 seconds when the "XX
secs left to system shutdown!" message is displayed.&nbsp; Something like
the attached patch??<br>
<br>
Thanks,<br>
Matt<br>
<br>
<br>
<br>
Matt Doran wrote:
<blockquote cite="mid46216F8A.6010107@papercut.biz" type="cite">Hi
there,
  <br>
  <br>
I have my myth box (0.20-fixes) configured to autoshutdown when idle.&nbsp;
I also make use of mythwelcome, etc, so that the machine isn't on
wasting power when it doesn't need to be.
  <br>
  <br>
It all works nicely, except it is common for it to shutdown, while a
transcode or commflag job is in progress.
  <br>
  <br>
Here's some sample output from last night's logs....
  <br>
  <br>
&nbsp;&nbsp; 2007-04-15 01:47:53.244 110 secs left to system shutdown!
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:03.316 100 secs left to system shutdown!
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:13.368 90 secs left to system shutdown!
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:23.417 80 secs left to system shutdown!
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:33.457 70 secs left to system shutdown!
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:43.509 60 secs left to system shutdown!
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:47.441 JobQueue: Currently set at 1 job(s) max and
  <br>
&nbsp;&nbsp; to run new jobs from 00:00 to 12:00
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:47.450 JobQueue: GetJobsInQueue: findJobs search
  <br>
&nbsp;&nbsp; bitmask 4, found 14 total jobs
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:47.477 JobQueue: GetJobsInQueue: Ignore 'Flag
  <br>
&nbsp;&nbsp; Commercials' Job for 2512 @ 20070412195900 in Finished state.
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:47.478 JobQueue: GetJobsInQueue: Ignore 'Transcode'
  <br>
&nbsp;&nbsp; Job for 2512 @ 20070412195900 in Finished state.
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:47.479 JobQueue: GetJobsInQueue: Ignore 'Flag
  <br>
&nbsp;&nbsp; Commercials' Job for 2512 @ 20070412222900 in Finished state.
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:47.480 JobQueue: GetJobsInQueue: Ignore 'Transcode'
  <br>
&nbsp;&nbsp; Job for 2512 @ 20070412222900 in Finished state.
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:47.481 JobQueue: GetJobsInQueue: Ignore 'Flag
  <br>
&nbsp;&nbsp; Commercials' Job for 2511 @ 20070413155900 in Finished state.
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:47.482 JobQueue: GetJobsInQueue: Ignore 'Transcode'
  <br>
&nbsp;&nbsp; Job for 2511 @ 20070413155900 in Finished state.
  <br>
&nbsp;&nbsp; *2007-04-15 01:48:47.483 JobQueue: GetJobsInQueue: Found 'Flag
  <br>
&nbsp;&nbsp; Commercials' Job for 2501 @ 20070413203236 in Running state.*
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:47.484 JobQueue: GetJobsInQueue: Found 'Transcode'
  <br>
&nbsp;&nbsp; Job for 2501 @ 20070413203236 in Queued state.
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:47.484 JobQueue: GetJobsInQueue: Found 'Flag
  <br>
&nbsp;&nbsp; Commercials' Job for 2501 @ 20070414142900 in Queued state.
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:47.485 JobQueue: GetJobsInQueue: Found 'Transcode'
  <br>
&nbsp;&nbsp; Job for 2501 @ 20070414142900 in Queued state.
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:47.486 JobQueue: GetJobsInQueue: Found 'Flag
  <br>
&nbsp;&nbsp; Commercials' Job for 2511 @ 20070414193400 in Queued state.
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:47.487 JobQueue: GetJobsInQueue: Found 'Transcode'
  <br>
&nbsp;&nbsp; Job for 2511 @ 20070414193400 in Queued state.
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:47.488 JobQueue: GetJobsInQueue: Found 'Flag
  <br>
&nbsp;&nbsp; Commercials' Job for 2501 @ 20070414230000 in Queued state.
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:47.489 JobQueue: GetJobsInQueue: Found 'Transcode'
  <br>
&nbsp;&nbsp; Job for 2501 @ 20070414230000 in Queued state.
  <br>
&nbsp;&nbsp; 2007-04-15 01:48:53.562 50 secs left to system shutdown!
  <br>
&nbsp;&nbsp; 2007-04-15 01:49:03.618 40 secs left to system shutdown!
  <br>
  <br>
  <br>
As you can see there is a commercial flag going (job 2501) ... but the
system still thinks that it needs to shutdown.&nbsp;&nbsp;&nbsp; So it seems that
there is a problem in the way that the backend detects if these jobs
are still running (i.e. it's idle detection).
  <br>
  <br>
I see plenty of this type of output.&nbsp; You see it counting down to
shutdown and then it restarts the counting.&nbsp; But eventually the system
will shutdown without completing the current job ... or any of the
others in the queue.&nbsp;&nbsp; The idle time is set to 120 secs and the job
queue is checked every 60 secs.
  <br>
  <br>
Anyone else seeing this?&nbsp; Any idea how to fix it?&nbsp; Is there a bug
hiding here somewhere?
  <br>
  <br>
Regards,
  <br>
Matt
  <br>
  <br>
  <br>
  <br>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
mythtv-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mythtv-users@mythtv.org">mythtv-users@mythtv.org</a>
<a class="moz-txt-link-freetext" href="http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users">http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users</a>
  </pre>
</blockquote>
</body>
</html>