3e74fa00eb48fc4537d316039d048652f3c6fc47
galt
  Fri Feb 12 13:16:31 2016 -0800
Workaround for unexpected error: lookup of key [...] in sameItem hash failed

diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c
index c2366dc..4a7e46c 100644
--- src/hg/hgTracks/simpleTracks.c
+++ src/hg/hgTracks/simpleTracks.c
@@ -418,31 +418,30 @@
 // allowOverflow is currently ONLY used by xenoMrna and est tracks.
 //  When true,  the extra rows are kept, printed at the bottom in dense and Last Row: overlow count appears at bottom of leftLabel area.
 //  When false, the extra rows are tossed, the count seems to equal overflow limit + 2, and limitVisibility lowers vis and retries.
 
 //warn("packCountRowsOverflow tg->track %s (%sfirst window) tg->visibility=%d tg->limitedVis=%d tg->limitedVisSet=%d vis=%d insideWidth=%d", 
 //tg->track, currentWindow == windows ? "" : "non-", tg->visibility, tg->limitedVis, tg->limitedVisSet, vis, insideWidth); // DEBUG REMOVE
 
 // do not calculate if still loading all windows
 if (trackLoadingInProgress) // we pack after all windows are loaded.
     {
     // do not set ss yet
     //warn("trackLoadingInProgress, exiting currentWindow=%lu windows=%lu", (unsigned long) currentWindow, (unsigned long) windows); // DEBUG REMOVE
     return 0;  // height of 0 triggers unsetting limitedVis since our data is not all loaded yet and it will get set later.
     }
 
-
 // do not re-calculate if not needed
 if (tg->ss)
     {
     if (tg->ss->window != currentWindow)
 	errAbort("unexpected current window %lu, expected %lu", (unsigned long) currentWindow, (unsigned long) tg->ss->window);
     struct spaceSaver *ss = findSpaceSaverAndFreeOldOnes(tg, vis);
     if (ss)
 	return ss->rowCount;
     // Falls thru here if a new visibility is needed, such as full changing to pack after limitVisibility.
     // This will usually be when it is the first window and it is requesting a new vis.
     }
 
 if (currentWindow != windows)  // if not first window
     {
     errAbort("unexpected current window %lu, expected first window %lu", (unsigned long) currentWindow, (unsigned long) windows);
@@ -539,31 +538,35 @@
 	int baseEnd = tg->itemEnd(tg, item);
 	if (baseStart < w->winEnd && baseEnd > w->winStart) 
 	    { // it intersects the window
 
 	    char *mapItemName = tg->mapItemName(tg, item);
 	    char key[1024];
 	    // TODO see key caveats above
 	    // For now, this should be good enough to illustrate the basic behavior we want to see.
 	    if (isTypeUseItemNameAsKey(tg))
 		safef(key, sizeof key, "%s",  tg->itemName(tg, item));
 	    else
 		safef(key, sizeof key, "%s:%d-%d %s", chrom, baseStart, baseEnd, mapItemName);
 	    //warn("spaceSaver key=[%s] window=%lu", key, (unsigned long)w); // DEBUG REMOVE
 	    struct hashEl *hel = hashLookup(sameItem, key);
 	    if (!hel)
+		{
+		if (tg->networkErrMsg) // probably timed-out before thread finished adding more items.
+		    break;
 		errAbort("unexpected error: lookup of key [%s] in sameItem hash failed.", key);
+		}
 	    struct sameItemNode *sin = (struct sameItemNode *)hel->val;
 	    if (!sin)
 		errAbort("sin empty (hel->val)!");
 	    if (!sin->done)
 		{ // still needs to be done
 		//warn("Reversed list."); // DEBUG REMOVE
 		slReverse(&hel->val);
 		sin = (struct sameItemNode *)hel->val;
 		}
 
 	    bool noLabel = FALSE;
 	    struct window *firstWin = sin->window;  // first window
 	    struct window *lastWin = NULL;
 	    bool foundWork = FALSE;