Opened 11 years ago

Closed 9 years ago

#6066 closed patch (fixed)

Wakeup time not set if Myth shuts down just before a scheduled recording

Reported by: bullestock@… Owned by: Isaac Richards
Priority: minor Milestone: unknown
Component: MythTV - Mythwelcome & Mythshutdown Version: head
Severity: medium Keywords: shutdown, wakeup
Cc: Ticket locked: no

Description (last modified by paulh)

This might be related to #6019, but the symptoms are a bit different.

I have attached the full mythbackend/mythshutdown logs, but these extracts show the gist of the problem:

Backend log:

2009-01-03 10:13:52.191 Scheduler: Update next_record for 317
--- print list start ---
Title - Subtitle                Ch Station Day Start  End   S C I  T N   Pri
Bratz - "Seje Filmstjerner"       3 TV2     03 10:20-11:25  1 1 1  S 1   1/0 
[...]
---  print list end  ---
2009-01-03 10:13:52.245 Scheduled 111 items in 1.5 = 0.03 match + 1.42 place
2009-01-03 10:14:18.370 I'm idle now... shutdown will occur in 60 seconds. 
[...]
2009-01-03 10:15:18.021 Running the command to set the next scheduled wakeup time :-
						sudo /usr/local/bin/mythshutdown --setwakeup 2009-01-03T10:15:00

Mythshutdown log:

2009-01-03 10:15:18.652 recording scheduled at: 2009-01-03T10:15:00
2009-01-03 10:15:18.652 scheduled recording time has already passed. schedule deleted 

So, in summary: The backend decides to shut down because the next recording is scheduled to start in 5 minutes and 50 seconds (my idleWaitForRecordingTime is 5 minutes). However, one minute later, when mythshutdown is called, it subtracts StartupSecsBeforeRecording? (set to 300 s = 5 min) and decides that it is too late to set the wakeup time. To make matters worse, it does not set the wakeup time to the next scheduled recording - it sets no wakeup time at all!

AFAICT, this will never happen as long as idleWaitForRecordingTime is at least a few minutes larger than StartupSecsBeforeRecording?, so as a workaround, I will set idleWaitForRecordingTime to ten minutes. A possible fix could be to enforce this.

Attachments (7)

backend.log (73.0 KB) - added by bullestock@… 11 years ago.
Backend log
shutdown.log (10.3 KB) - added by bullestock@… 11 years ago.
mythshutdown log
6060_1.diff (833 bytes) - added by laga 10 years ago.
Patch against backend
6060_2.diff (1008 bytes) - added by laga 10 years ago.
Patch against Mythwelcome.
6060_1-1.diff (1.2 KB) - added by laga 10 years ago.
6066_3.diff (774 bytes) - added by ralfd 9 years ago.
Simple patch of MythWelcome?
patch.diff (3.9 KB) - added by ralfd 9 years ago.
patch to fix the shutdown issue

Download all attachments as: .zip

Change History (20)

Changed 11 years ago by bullestock@…

Attachment: backend.log added

Backend log

Changed 11 years ago by bullestock@…

Attachment: shutdown.log added

mythshutdown log

comment:1 Changed 10 years ago by paulh

Description: modified (diff)

Changed 10 years ago by laga

Attachment: 6060_1.diff added

Patch against backend

Changed 10 years ago by laga

Attachment: 6060_2.diff added

Patch against Mythwelcome.

comment:2 Changed 10 years ago by laga

I've attached two patches. 6060_1.diff is against the backend:

6060_2.diff is against mythwelcome:

  • If we want to shut down and the wakeup time (or time for the next recording in mythshutdown terms - slightly confusing) is less than 100s in the past, assume that we should be awake and abort the shutdown.

These patches need some review because I'm not sure if I got the big picture. It'd also be good if the OP could try those. The second patch is not really necessary, I just added it to avoid a race condition where Mythbackend decides it's okay to call mythshutdown and for whatever reason that call takes enough for mythshutdown to decide that the startup time is in the past.

comment:3 Changed 10 years ago by laga

Type: defectpatch
Version: 0.21-fixeshead

Ignore 6066_1.diff - it's broken. We want to use idleWaitForRecordingTime. Please use 6060_1-1.diff.

Changed 10 years ago by laga

Attachment: 6060_1-1.diff added

comment:4 Changed 10 years ago by stuartm

Component: mythshutdownMythTV - Mythwelcome & Mythshutdown

comment:5 Changed 9 years ago by ralfd

A small change in welcomedialog.cpp should take care of this:

void WelcomeDialog::updateStatusMessage(void) {

m_statusList.clear();

QDateTime curtime = QDateTime::currentDateTime();

if (!m_isRecording && !m_nextRecordingStart.isNull() &&

curtime.secsTo(m_nextRecordingStart) - m_preRollSeconds - m_secondsToShutdown < m_idleWaitForRecordingTime * 60)

{

m_statusList.append(tr("MythTV is about to start recording."));

}

comment:6 Changed 9 years ago by robertm

Status: newinfoneeded_new

ralfd, mind attaching as a unified diff so we can get the reporter to test it?

Changed 9 years ago by ralfd

Attachment: 6066_3.diff added

Simple patch of MythWelcome?

comment:7 Changed 9 years ago by robertm

Status: infoneeded_newnew

comment:8 Changed 9 years ago by robertm

Status: newinfoneeded_new

Resetting clock on infoneeded-- bullestock, can you please apply ralfd's patch and let us know if it fixes your issue?

comment:9 in reply to:  5 Changed 9 years ago by ralfd

Ok, I guess I was a little too optimistic. There a a few different code sections that control this behaviour, not only the one I changed so far.

I was able to reproduce the behaviour that was reported by bullestock. The problem is that the code does not consider the time we give the backend prior to shutting down (m_secondsToShutdown). Most people probably have this value set pretty low (60 or 120s). Therefore it is rather unlikely that it becomes a problem. One would have to exit the frontend exactly within that timeframe prior to the next system start-up in order to have problems with it. The higher m_secondsToShutdown is the higher the probability that it becomes an issue.

I will dig into the code a little more when time allows and hope to be able to present a clean fix for this issue soon.

Don't bother applying the patch I uploaded.

Replying to ralfd:

A small change in welcomedialog.cpp should take care of this:

void WelcomeDialog::updateStatusMessage(void) {

m_statusList.clear();

QDateTime curtime = QDateTime::currentDateTime();

if (!m_isRecording && !m_nextRecordingStart.isNull() &&

curtime.secsTo(m_nextRecordingStart) - m_preRollSeconds - m_secondsToShutdown < m_idleWaitForRecordingTime * 60)

{

m_statusList.append(tr("MythTV is about to start recording."));

}

Changed 9 years ago by ralfd

Attachment: patch.diff added

patch to fix the shutdown issue

comment:10 Changed 9 years ago by ralfd

My last patch fixes the issue in mythbackend and mythwelcome.

comment:11 Changed 9 years ago by robertm

Status: infoneeded_newnew

comment:12 Changed 9 years ago by robertm

(In [24429]) Refs #6066. Take into account the idletimeoutsecs setting when deciding whether to shut down/wake up the system.

comment:13 Changed 9 years ago by robertm

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.