Opened 20 months ago
Closed 20 months ago
MSqlDatabase::Reconnect() should also reset session parameters set by OpenDatabase()
|Reported by:||Adrian Saul <sgtbundy@…>||Owned by:||gigem|
|Component:||MythTV - MythSystem||Version:||Master Head|
Since upgrading to 0.26 I have had an issue where upcoming scheduled recordings disappear. After much trouble shooting, it was tracked down to a combination of my timezone, and the schedulers use of NOW() to filter programs based on ending time.
When the scheduler starts it opens a dedicated database session, which in InitDatabase?() the mysql session.time_zone is set to UTC (+00:00). With some debugging code I was able to prove the problem to be that NOW() was returning local time instead of UTC as needed by the scheduler:
Sep 13 04:11:28 pvr mythlogserver: mythbackend: D Scheduler scheduler.cpp:2104 (HandleReschedule?) Result for NOW() is 2012-09-12T18:11:28
Sep 13 16:16:32 pvr mythlogserver: mythbackend: D Scheduler scheduler.cpp:2104 (HandleReschedule?) Result for NOW() is 2012-09-13T16:16:32
Just prior to this occurring there was a reconnect message for the Schedulers database session:
Sep 13 16:16:32 pvr mythlogserver: mythbackend: I Scheduler mythdbcon.cpp:243 (Reconnect) MySQL reconnected successfully
In Reconnect(), it closes and opens the database connection but does not re-apply the session parameters. This means should the schedulers session get timed out, the session will be re-established in local time (or the database default) and not UTC as needed by the scheduler. In my case being a GMT+10 timezone this was causing a scheduler SQL clause to fail resulting in anything ending in the next 2 hours to be dropped from the scheduled recordings.
I believe the fix is to force the session parameters to be reset when Reconnect() is called. I have attached a simple patch for this, but probably a cleaner method would be to define a SetupSession?() function which could be called by both InitDatabase?() and Reconnect() to properly setup the session should additional session parameters be needed in the future.
Change History (3)
Changed 20 months ago by Adrian Saul <sgtbundy@…>
comment:1 Changed 20 months ago by gigem
- Owner changed from beirdo to gigem
- Priority changed from minor to blocker
- Severity changed from medium to high
- Status changed from new to accepted
comment:2 Changed 20 months ago by David Engel <dengel@…>
- Resolution set to fixed
- Status changed from accepted to closed