[mythtv-users] Mythfrontend QUERY_RECORDINGS timeout - hangs frontend

Tony Lill ajlill at ajlc.waterloo.on.ca
Fri Sep 21 20:46:08 UTC 2007


The problem is that a query recording returns the ENTIRE contents of
the recorded table, every time it runs, which is a lot. If you have
enough recordings, this can take a very long time and give you the
timeouts you are seeing.

0.21 has added caching of this data on the frontend which supposedly
will fix it. It also removed the code which checks for the existence
of the actual files, which can be held up by disk spin-up or
automounting, if you use these. If you're using 0.21 and still have
problems, you should issue a bug report.

If you are using 0.20 and don't mind getting your hands dirty, here's
a patch which solved the problem for me by only returning info for
the group you are looking at, and turning off the file checks.

Index: libs/libmythtv/tv_play.cpp
===================================================================
--- libs/libmythtv/tv_play.cpp	(revision 14478)
+++ libs/libmythtv/tv_play.cpp	(working copy)
@@ -6144,8 +6144,9 @@
     // Build jumpMenu of recorded program titles
     ProgramInfo *p;
     progLists.clear();
+    QString whereClause = " and recorded.recgroup = \"" + playbackinfo->recgroup + "\"";
     vector<ProgramInfo *> *infoList;
-    infoList = RemoteGetRecordedList(false);
+    infoList = RemoteGetRecordedList(false, whereClause);
 
     bool LiveTVInAllPrograms = gContext->GetNumSetting("LiveTVInAllPrograms",0);
 
Index: libs/libmythtv/remoteutil.cpp
===================================================================
--- libs/libmythtv/remoteutil.cpp	(revision 14478)
+++ libs/libmythtv/remoteutil.cpp	(working copy)
@@ -6,13 +6,14 @@
 #include "mythcontext.h"
 #include "remoteencoder.h"
 
-vector<ProgramInfo *> *RemoteGetRecordedList(bool deltype)
+vector<ProgramInfo *> *RemoteGetRecordedList(bool deltype, QString whereClause)
 {
     QString str = "QUERY_RECORDINGS ";
     if (deltype)
         str += "Delete";
     else
         str += "Play";
+    str += whereClause;
 
     QStringList strlist = str;
 
Index: libs/libmythtv/remoteutil.h
===================================================================
--- libs/libmythtv/remoteutil.h	(revision 14478)
+++ libs/libmythtv/remoteutil.h	(working copy)
@@ -19,7 +19,7 @@
     long long usedSpaceKB;
 };
 
-vector<ProgramInfo *> *RemoteGetRecordedList(bool deltype);
+vector<ProgramInfo *> *RemoteGetRecordedList(bool deltype, QString where);
 vector<FileSystemInfo> RemoteGetFreeSpace();
 bool RemoteGetLoad(float load[3]);
 bool RemoteGetUptime(time_t &uptime);
--- programs/mythfrontend/playbackbox.cpp	(revision 14478)
+++ programs/mythfrontend/playbackbox.cpp	(working copy)
@@ -1479,8 +1479,15 @@
 
     bool LiveTVInAllPrograms = gContext->GetNumSetting("LiveTVInAllPrograms",0);
 
+    QString whereClause = "";
+    if( recGroup != "All Programs" ) {
+      if(recGroupType[recGroup] == "category")
+	whereClause = " and recorded.category = \"" + recGroup + "\"";
+      else
+	whereClause = " and recorded.recgroup = \"" + recGroup + "\"";
+    }	
     vector<ProgramInfo *> *infoList;
-    infoList = RemoteGetRecordedList(listOrder == 0 || type == Delete);
+    infoList = RemoteGetRecordedList(listOrder == 0 || type == Delete, whereClause);
     if (infoList)
     {
         sortedList[""] = "";
Index: programs/mythbackend/mainserver.h
===================================================================
--- programs/mythbackend/mainserver.h	(revision 14478)
+++ programs/mythbackend/mainserver.h	(working copy)
@@ -72,7 +72,7 @@
     void HandleDone(MythSocket *socket);
 
     void HandleIsActiveBackendQuery(QStringList &slist, PlaybackSock *pbs);
-    void HandleQueryRecordings(QString type, PlaybackSock *pbs);
+    void HandleQueryRecordings(QStringList &tokens, PlaybackSock *pbs);
     void HandleStopRecording(QStringList &slist, PlaybackSock *pbs);
     void DoHandleStopRecording(ProgramInfo *pginfo, PlaybackSock *pbs);
     void HandleDeleteRecording(QStringList &slist, PlaybackSock *pbs,
Index: programs/mythbackend/mainserver.cpp
===================================================================
--- programs/mythbackend/mainserver.cpp	(revision 14478)
+++ programs/mythbackend/mainserver.cpp	(working copy)
@@ -351,10 +351,10 @@
 
     if (command == "QUERY_RECORDINGS")
     {
-        if (tokens.size() != 2)
+        if (tokens.size() < 2)
             VERBOSE(VB_IMPORTANT, "Bad QUERY_RECORDINGS query");
         else
-            HandleQueryRecordings(tokens[1], pbs);
+            HandleQueryRecordings(tokens, pbs);
     }
     else if (command == "QUERY_FREE_SPACE")
     {
@@ -1003,11 +1003,13 @@
     }
 }
 
-void MainServer::HandleQueryRecordings(QString type, PlaybackSock *pbs)
+void MainServer::HandleQueryRecordings(QStringList &tokens, PlaybackSock *pbs)
 {
+  QString type = tokens[1];
     MythSocket *pbssock = pbs->getSocket();
     bool islocal = pbs->isLocal();
     QString playbackhost = pbs->getHostname();
+    int i;
 
     QString fs_db_name = "";
 
@@ -1074,8 +1076,11 @@
         "  recorded.progstart = recordedprogram.starttime ) "
         "WHERE ( recorded.deletepending = 0 OR "
         "        DATE_ADD(recorded.lastmodified, INTERVAL 5 MINUTE) <= NOW() "
-        "      ) "
-        "ORDER BY recorded.starttime";
+      "      )";
+    for( i = 2; i < tokens.size(); i++ ) {
+      thequery += " "+tokens[i];
+    }
+        thequery += " ORDER BY recorded.starttime";
 
     if (type == "Delete")
         thequery += " DESC";
@@ -1215,14 +1220,14 @@
 
             QString lpath = fileprefix + "/" + basename;
             PlaybackSock *slave = NULL;
-            QFile checkFile(lpath);
+            //QFile checkFile(lpath);
 
             if (proginfo->hostname != gContext->GetHostName())
                 slave = getSlaveByHostname(proginfo->hostname);
 
-            if ((masterBackendOverride && checkFile.exists()) || 
+            if ((masterBackendOverride /*&& checkFile.exists()*/) || 
                 (proginfo->hostname == gContext->GetHostName()) ||
-                (!slave && checkFile.exists()))
+                (!slave /*&& checkFile.exists()*/))
             {
                 if (islocal)
                     proginfo->pathname = lpath;


More information about the mythtv-users mailing list