[mythtv-commits] mythtv/master commit: 4dfcdb8dd by Daniel Kristjansson (daniel-kristjansson)

MythTV noreply at mythtv.org
Thu Aug 4 20:18:53 UTC 2011


      Author:  Daniel Kristjansson <danielk at cuymedia.net>
 Change Date:  2011-08-04T13:00:38-07:00
   Push Date:  2011/08/04 13:18:47 -0700
  Repository:  mythtv
      Branch:  master
New Revision:  4dfcdb8dd0c80d096ed95d5eccd489c692efa90d
   Changeset:  https://github.com/MythTV/mythtv/commit/4dfcdb8dd

Log:

Fix SQL reconnection logic. Refs #9704. Refs #9773. Refs #9792.

What this does is get rid of the old KickDatabase() logic and replaces it
with a simple reconnect if the DB socket is disconnected, and also gets
rid of a recent re-enablement of the automatic reconnects in [dd2d7a14d1]
and importantly it extends the reconnection logic in [528324d8ba] so that
it resends the prepare() and rebinds the bindings when a reconnect happens
in an exec().

This also makes the QSqlQuery parent of MSqlQuery private and adds some
wrappers so we can prevent MSqlQuery users from accessing methods that
may invalidate some assumption in MSqlQuery + it adds debugging wrappers
for first(), last(), previous(), and seek() like we already had for next().

A little bit of history is in order.

In Qt3 the SQL driver automatically reconnected whenever a connection was lost.
But the first query after this auto-reconnect always failed. So in 2003 mdz
added KickDatabase() which would recover disconnect and reconnect an
automatically all was good with the world.

In Qt4 the QSqlQuery::prepare() started to actually do prepared statements
instead of emulating them. This caused a small problem in now it was possible
that a disconnect happened between the call to prepare() and exec() and then
the exec() would fail. But odds of this were still pretty low for most uses
of the database in MythTV. But at some point trolltech also got rid of the
automatic reconnections which caused us trouble in Qt3. To fix this we added
reconnection logic in [528324d8ba] and this is where the real trouble began.
While this reconnection logic really does exactly the same thing that the
auto-reconnection logic did in Qt3, the fact that prepare() doesn't just emulate
prepared statements in Qt4 means that it's now that when we reconnect to the
database in exec() the prepared statement has not been sent to the database.

Note: This should be back-ported to 0.24-fixes after a reasonable burn-in time in master.

Modified:

   mythtv/libs/libmyth/programinfo.cpp
   mythtv/libs/libmythbase/mythdb.cpp
   mythtv/libs/libmythbase/mythdb.h
   mythtv/libs/libmythbase/mythdbcon.cpp
   mythtv/libs/libmythbase/mythdbcon.h
   mythtv/libs/libmythbase/mythversion.h
   mythtv/libs/libmythtv/datadirect.cpp
   mythtv/libs/libmythtv/dbcheck.cpp
   mythtv/programs/mythbackend/httpstatus.cpp
   mythtv/programs/mythbackend/main_helpers.cpp
   mythtv/programs/mythbackend/mainserver.cpp
   mythtv/programs/mythbackend/scheduler.cpp
   mythtv/programs/mythfrontend/progfind.cpp



More information about the mythtv-commits mailing list