[mythtv-commits] Ticket #10136: EIT update gives DB Error about duplicate primary keys
MythTV
noreply at mythtv.org
Sun Oct 30 09:09:22 UTC 2011
#10136: EIT update gives DB Error about duplicate primary keys
-----------------------------------------+---------------------------------
Reporter: klaas.de.waal@… | Owner: stuarta
Type: Patch - Bug Fix | Status: new
Priority: minor | Milestone: unknown
Component: MythTV - EIT | Version: Trunk Head
Severity: medium | Keywords: eit duplicate key
Ticket locked: 0 | ziggo
-----------------------------------------+---------------------------------
I have been getting messages like this:
{{{
2011-10-17 21:43:36.939617 E DB Error (change_program):
Query was:
UPDATE program SET starttime = ?, endtime = ? WHERE chanid = ?
AND starttime = ?
Bindings were:
:CHANID=1903, :NEWEND=2011-10-18T13:55:00, :NEWSTART=2011-10-18T12:10:00,
:OLDSTART=2011-10-18T12:00:00
Driver error was [2/1062]:
QMYSQL3: Unable to execute statement
Database error was:
Duplicate entry '1903-2011-10-18 12:10:00-0' for key 'PRIMARY'
}}}
in my backend log for years.
[[BR]]
In my case, with the EIT information from DVB-C provider Ziggo in the
Netherlands, most (but not all) of the database conflicts are caused by
dummy program entries "Zender verstrekt geen informatie" (in English:
"Broadcaster does not provide information"). For a number of TV channels,
the dummy entries are there already four days in the future while the real
program information appears three days in the future.
[[BR]]
The result of the DB errors is that the dummy entries remain in the
database while the new entries, with real program information, are
discarded.
[[BR]]
[[BR]]
What happens is the following.
[[BR]]
We start in libs/libmythtv/programdata.cpp in function MoveOutOfTheWayDB
in the section "starts during, but ends after our program".
[[BR]]
There we call change_program to move the start time of the overlapping
program to the end time of our new program, to make space in the EPG for
our new program. We have a problem if there is already a program that
starts at the end time of our new program; if we then try to change the
start time of the overlapping program to the end time of our new program
we get the duplicate primary key error.
[[BR]]
The result is that MoveOutOfTheWayDB returns false, the new EPG entry is
discarded and the old entry (the one that we could not move) remains in
the database.
[[BR]]
[[BR]]
I have now added a check to see if there is already a program in the
database that starts at the end time of our new program. If that is the
case, the overlapping program is deleted. If that is not the case then we
can safely change the start time of the overlapping program without
generating a database error.
[[BR]]
This solution works for me and the MythTV guide is now almost identical to
the guide that is presented by my TV set from the same DVB-C video source.
[[BR]]
[[BR]]
The patch for programdata.cpp is attached.
[[BR]]
[[BR]]
Checked with MythTV version:
{{{
[klaas at modu log]$ mythbackend --version
Please attach all output as a file in bug reports.
MythTV Version : v0.25pre-3634-g98a0304-dirty
MythTV Branch : master
Network Protocol : 69
Library API : 0.25.20111023-1
QT Version : 4.7.3
Options compiled in:
linux debug use_hidesyms using_alsa using_oss using_pulse
using_pulseoutput using_backend using_bindings_perl using_bindings_python
using_bindings_php using_dvb using_frontend using_hdhomerun using_hdpvr
using_iptv using_ivtv using_joystick_menu using_libxml2 using_lirc
using_mheg using_opengl_video using_qtwebkit using_qtscript using_qtdbus
using_v4l2 using_v4l1 using_x11 using_xrandr using_xv using_bindings_perl
using_bindings_python using_bindings_php using_mythtranscode using_opengl
using_ffmpeg_threads using_live using_mheg using_libass using_libxml2
}}}
N.B. I have attached this bug report and the fix previously to bug #2342,
which seems to report the same problem. On advice of mdean this is now
reported on a new ticket.
--
Ticket URL: <http://code.mythtv.org/trac/ticket/10136>
MythTV <http://code.mythtv.org/trac>
MythTV Media Center
More information about the mythtv-commits
mailing list