2008-12-22, 09:26 PM
While looking into occasional crashes caused by the database being locked, I discovered that making a number (40 to 100) of calls to SheduleRecording() in a short period of time would lock the database. Sometimes after a number of 30 second timeouts the database would recover and GBPVR would respond to inputs, but most often it would have to be killed with the task manager and then restarted.
To demonstrate the problem I added the following code to sub's HelloWorld example:
The test code attempts to schedule four days of consecutive programs on the same channel when one of the buttons is selected. If the database is locked and then recovers after a 30 second timeout, the program is not added to RECORDING_SCHEDULE but the failure is not indicated by the returned ScheduleRecording being null. Slowing the test program with calls to Thread.Sleep() keeps the database from being locked.
The attached logs are from a run on a new installation of GBPVR (RECORDING_SCHEDULE was empty) where the 98th call to SheduleRecording() locked the database.
System: 2.4 GHz Intel CoreDual, 3 GB ram, XP Pro/sp3, HVR-1600
To demonstrate the problem I added the following code to sub's HelloWorld example:
Code:
protected override void handleCommand(string command)
{
... snip ...
case "Button 3":
// start of SheduleRecording() test code
Logger.Verbose("** Starting");
IScheduleHelper scheduleHelper = ScheduleHelper.getInstance();
IList allChannels = scheduleHelper.GetListingsForTimePeriod(DateTime.Now.AddDays(1.0), DateTime.Now.AddDays(5.0));
IList programmeList = ((Channel)allChannels[0]).getProgrammeList();
Logger.Verbose(string.Format("** About to schedule {0} recordings", programmeList.Count));
int cnt = 0;
foreach (Programme programme in programmeList)
{
cnt++;
Logger.Verbose(string.Format("** About to schedule {0,4} {1}", cnt, programme.getTitle()));
ScheduledRecording scheduledRecording = scheduleHelper.SheduleRecording(
programme.getChannelOID(), programme.getStartTime(),
programme.getEndTime(), programme, 0, 0, programme.getTitle());
Logger.Verbose(string.Format("** ScheduleRecording.status: {0}",
scheduledRecording == null ? "NULL" : scheduledRecording.getRecordingStatus().ToString()));
}
Logger.Verbose("** Finished");
// end of SheduleRecording() test code
setPopup(new GBPVRX2.Popups.PopupMessageBox(this, "The user clicked " + command, "OK", "Cancel"));
... snip ...
}
The test code attempts to schedule four days of consecutive programs on the same channel when one of the buttons is selected. If the database is locked and then recovers after a 30 second timeout, the program is not added to RECORDING_SCHEDULE but the failure is not indicated by the returned ScheduleRecording being null. Slowing the test program with calls to Thread.Sleep() keeps the database from being locked.
The attached logs are from a run on a new installation of GBPVR (RECORDING_SCHEDULE was empty) where the 98th call to SheduleRecording() locked the database.
System: 2.4 GHz Intel CoreDual, 3 GB ram, XP Pro/sp3, HVR-1600