[mythtv] Race condition in scheduler during pre-roll interval

Andrew M. Bishop amb at gedanken.demon.co.uk
Sun Jan 18 12:39:28 EST 2004


There is a race condition that will allow a program to get recorded
twice at the same time on a dual tuner system (with version 0.13).  It
looks to me that the problem occurs when there is a change in the
RecordChanged value in the database settings during the pre-roll
period.

The log file below from mythbackend shows this happening.  I have a
pre-roll interval of 1 minute.  At 16:09:01, 1 minute before the
program started, the first tuner card started recording.  Just before
the end of the minute a change was found (due to me selecting a new
program to record).  A second copy of the same program started
recording at 16:09:55 on the second tuner.

-------------------- mythbackend log file --------------------
2004-01-18 13:24:51 Found changes in the todo list.
2004-01-18 16:09:01 Started recording "Robot Wars" on channel: 5 on cardid: 4, sourceid 1
2004-01-18 16:09:01 Changing from None to RecordingOnly
2004-01-18 16:09:01 Using profile 'Default' to record
--- print list start ---
Title                 Chan  ChID  StartTime       S I C  C R O N Priority Total
Enterprise              50  6  Jan 18 04:00pm  1 4 5  0 0 0 D        0    1
Robot Wars              50  5  Jan 18 04:10pm  1 4 5  0 1 0 -        0    0
Futurama                50  6  Jan 18 05:00pm  1 4 5  0 0 0 P        0    1
...
[snipped rest of list]
...
---  print list end  ---
2004-01-18 16:09:55 Found changes in the todo list.
2004-01-18 16:09:55 Started recording "Robot Wars" on channel: 5 on cardid: 5, sourceid 1
2004-01-18 16:09:55 Changing from None to RecordingOnly
2004-01-18 16:09:55 Using profile 'Default' to record
-------------------- mythbackend log file --------------------


When I tried again deliberately to make this happen I had partial
success.  During the pre-roll time for a recording, after the program
had started recording, I selected a program from tomorrow.  This
caused the backend to see a change in the list try to start recording
another copy of the current program, but it failed with a database
error.

DB Error (WriteRecordedToDB):
Query was:
INSERT INTO recorded (chanid,starttime,endtime,title,subtitle,description,hostname,category,autoexpire) VALUES(...);
Driver error was [2/1062]:
QMYSQL3: Unable to execute query
Database error was:
Duplicate entry '4-20040118172900' for key 1

This came after a message telling me that it was starting to record
the same program with the other tuner card.

I think that the reason that the first program in the log file above
suceeded in being recorded twice is that the start time of the second
recording was 1 minute different from the first recording.

-- 
Andrew.
----------------------------------------------------------------------
Andrew M. Bishop                             amb at gedanken.demon.co.uk
                                      http://www.gedanken.demon.co.uk/


More information about the mythtv-dev mailing list