src/hg/lib/customFactory.c 1.115

1.115 2010/01/29 21:49:46 galt
emergency fix for customTrash db server going offline
Index: src/hg/lib/customFactory.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/customFactory.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -b -B -U 4 -r1.114 -r1.115
--- src/hg/lib/customFactory.c	20 Jan 2010 17:45:58 -0000	1.114
+++ src/hg/lib/customFactory.c	29 Jan 2010 21:49:46 -0000	1.115
@@ -2028,11 +2028,27 @@
 char *line = NULL;
 struct hash *chromHash = newHash(8);
 float prio = 0.0;
 struct sqlConnection *ctConn = NULL;
+char *ctConnErrMsg = NULL;
 boolean dbTrack = ctDbUseAll();
 if (dbTrack)
+    {
+    /* protect against temporarily offline CT trash server */
+    struct errCatch *errCatch = errCatchNew();
+    if (errCatchStart(errCatch))
+        {
     ctConn = hAllocConn(CUSTOM_TRASH);
+        }
+    errCatchEnd(errCatch);
+    if (errCatch->gotError)
+        {
+	ctConnErrMsg = cloneString(errCatch->message->string);
+        }
+    errCatchFree(&errCatch);
+    /* warnings from here are not visible to user because of higher-level catching
+     * if we want to make the warning visible, have to extend behavior of customTrack.c */
+    }
 
 struct lineFile *lf = customLineFile(text, isFile);
 
 /* wrap a customPp object around it. */
@@ -2085,10 +2101,12 @@
     if (track->dbDataLoad)
     /* Database tracks already mostly loaded, just check that table 
      * still exists (they are removed when not accessed for a while). */
         {
-	if (!ctConn || !ctDbTableExists(ctConn, track->dbTableName))
+	if (ctConn && !ctDbTableExists(ctConn, track->dbTableName))
 	    continue;
+	if (!ctConn && ctConnErrMsg) 
+	    track->networkErrMsg = ctConnErrMsg;
 	if ( startsWith("maf", track->tdb->type))
 	    {
 	    struct hash *settings = track->tdb->settingsHash;
 	    char *fileName;