9c20ec91f0ecd76e8fad18fa0e381c8be894236b
braney
  Thu Jun 18 12:35:00 2020 -0700
if the trackDb table has changed in the last five minutes, avoid caching
because the table may not be done changing.  Updates are not atomic.

diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c
index 309e04c..51d950f 100644
--- src/hg/lib/hdb.c
+++ src/hg/lib/hdb.c
@@ -4159,37 +4159,46 @@
 
 if (doCache)
     {
     struct slName *tableList = hTrackDbList();
 
     struct sqlConnection *conn = hAllocConn(db);
     time_t newestTime = 0;
     for(; tableList; tableList = tableList->next)
         {
         time_t tableTime = sqlTableUpdateTime(conn, tableList->name);
         newestTime = tableTime > newestTime ? tableTime : newestTime;
         }
 
     hFreeConn(&conn);
 
+    long now = clock1();
+
+    // if the trackDb table has changed in the last five minutes, avoid caching because the table may
+    // not be done changing.  Updates are not atomic.
+    if (now - newestTime < 5 * 60)
+        doCache = 0;
+    else
+        {
         struct trackDb *cacheTdb = trackDbCache(db, tdbPathString, newestTime);
 
         if (cacheTdb != NULL)
             return cacheTdb;
         
         memCheckPoint(); // we want to know how much memory is used to build the tdbList
         }
+    }
 
 tdbList = loadTrackDb(db, NULL);
 tdbList = trackDbLinkUpGenerations(tdbList);
 tdbList = trackDbPolishAfterLinkup(tdbList, db);
 
 if (doCache)
     trackDbCloneTdbListToSharedMem(db, tdbPathString, tdbList, memCheckPoint());
 
 return tdbList;
 }
 
 static struct trackDb *loadAndLookupTrackDb(struct sqlConnection *conn,
 					    char *where)
 /* Load trackDb object(s). Nothing done for composite tracks here. */
 {