[mythtv] PATCH: Database check/repair at backend startup

Martin Smith martin at spamcop.net
Mon Oct 25 11:03:07 UTC 2004


Folks,

I recently got bitten by a couple of corrupt mysql tables after a hardware fault
so this patch is the result.

Very early in backend startup it calls CHECK TABLE FAST on all the tables in the
mythconverg database. If any tables fail to return a good status it calls REPAIR
TABLE on them.

If the REPAIR fails it writes a message but doesn't prevent backend startup.
These
messages should be investigated as soon as possible though. Messages will look
like: "*** Database repair on table whatever_table FAILED. Investigate!" and
will apppear almost immediately the backend starts.

The attached patch consists of trivial diffs + 2 small new files.

Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dbrepair.h
Type: text/x-chdr
Size: 232 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-dev/attachments/20041025/2ad2af6f/dbrepair.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dbrepair.cpp
Type: text/x-c++src
Size: 2047 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-dev/attachments/20041025/2ad2af6f/dbrepair.cpp
-------------- next part --------------
Index: libs/libmythtv/dbcheck.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/dbcheck.h,v
retrieving revision 1.1
diff -u -r1.1 dbcheck.h
--- libs/libmythtv/dbcheck.h	17 Sep 2003 16:53:55 -0000	1.1
+++ libs/libmythtv/dbcheck.h	25 Oct 2004 10:55:26 -0000
@@ -1,7 +1,7 @@
 #ifndef DBCHECK_H_
 #define DBCHECK_H_
 
-// Call after initialing the main db connection.
+// Call after initializing the main db connection.
 void UpgradeTVDatabaseSchema(void);
 
 #endif
Index: libs/libmythtv/libmythtv.pro
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/libmythtv.pro,v
retrieving revision 1.76
diff -u -r1.76 libmythtv.pro
--- libs/libmythtv/libmythtv.pro	24 Oct 2004 01:43:18 -0000	1.76
+++ libs/libmythtv/libmythtv.pro	25 Oct 2004 10:55:27 -0000
@@ -48,7 +48,7 @@
 HEADERS += fifowriter.h filtermanager.h videooutbase.h videoout_null.h xbox.h
 HEADERS += dbcheck.h udpnotify.h channeleditor.h channelsettings.h
 HEADERS += osdlistbtntype.h blend.h datadirect.h sr_dialog.h
-HEADERS += sr_items.h sr_root.h recordingtypes.h jobqueue.h
+HEADERS += sr_items.h sr_root.h recordingtypes.h jobqueue.h dbrepair.h
 
 SOURCES += commercial_skip.cpp frequencies.c guidegrid.cpp #infodialog.cpp 
 SOURCES += infostructs.cpp jitterometer.cpp minilzo.cpp NuppelVideoPlayer.cpp 
@@ -61,7 +61,7 @@
 SOURCES += udpnotify.cpp channeleditor.cpp channelsettings.cpp
 SOURCES += osdsurface.cpp osdlistbtntype.cpp blend.c datadirect.cpp
 SOURCES += sr_dialog.cpp sr_root.cpp sr_items.cpp decoderbase.cpp
-SOURCES += recordingtypes.cpp jobqueue.cpp
+SOURCES += recordingtypes.cpp jobqueue.cpp dbrepair.cpp
 
 
 linux {
Index: programs/mythbackend/main.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/main.cpp,v
retrieving revision 1.78
diff -u -r1.78 main.cpp
--- programs/mythbackend/main.cpp	23 Oct 2004 20:00:03 -0000	1.78
+++ programs/mythbackend/main.cpp	25 Oct 2004 10:55:28 -0000
@@ -24,6 +24,7 @@
 #include "libmythtv/programinfo.h"
 #include "libmyth/mythcontext.h"
 #include "libmythtv/dbcheck.h"
+#include "libmythtv/dbrepair.h"
 #include "libmythtv/jobqueue.h"
 
 QMap<int, EncoderLink *> tvList;
@@ -474,6 +475,7 @@
         return -1;
     }
 
+    CheckAndRepairDatabase();
     UpgradeTVDatabaseSchema();
 
     if (printsched || testsched)


More information about the mythtv-dev mailing list