b79f8a6f8375d675a5c7bf3b81ea7f9a9d57dad5 max Mon Jul 19 03:42:14 2021 -0700 adding local-only assemblies to GBIB/GBIC, refs #27865 diff --git src/hg/lib/jksql.c src/hg/lib/jksql.c index 03e537c..ec6661a 100644 --- src/hg/lib/jksql.c +++ src/hg/lib/jksql.c @@ -1243,49 +1243,70 @@ * not connected yet, as indicated by a NULL mysql connection pointer */ { static struct sqlConnection *sc; AllocVar(sc); sc->conn = NULL; sc->profile = profile; // remember the profile, needed to connect later sc->db = cloneString(database); sc->hasTableCache = -1; // -1 => undefined return sc; } static struct sqlConnection *sqlConnProfile(struct sqlProfile* sp, char *database, boolean abort) /* Connect to database using the profile. Database maybe NULL to connect to * the server. Optionally abort on failure. */ { +fprintf(stderr, "SQL_CONNECT_PROFILE %s %s %s\n", sp->name, sp->host, database); bool mainAbort = abort; struct sqlConnection *sc; // get the failover profile for the profile, if it exists struct sqlProfile *failoverProf = sqlProfileGetFailover(sp, database); // if we have a failover profile, don't abort right away if (failoverProf!=NULL) mainAbort = FALSE; // connect with the default profile sc = sqlConnRemote(sp, database, mainAbort); if (failoverProf==NULL) // the default case, without a failover connection: just return sc, can be NULL return sc; -// we still have a failover profile to setup: - +// local-only databases must never use the failover connection +// The alternative would be to not use a failover connection for any database that does not have a +// a tableList table, but then if the UCSC admins ever forget to create +// tableList tables, there would be no error and users would simply not see the +// remote tables anymore. We prefer a clear config statement where the local +// admin has to list the databases that do not exist on the public mysql +// server. +// Another alternative would be keep the main connection "hanging" (see below), but that would +// cost time at some point later. It's fastest to never connect at all for local-only assemblies. +char cfgName[255]; +safef(cfgName, sizeof(cfgName), "%s.excludeDbs", failoverProf->name); +char *failOverExclude = cfgOption(cfgName); +if (failOverExclude) +{ + struct slName *noFoDbs = slNameListFromString(failOverExclude, ','); + if (slNameInList(noFoDbs, database)) + { + fprintf(stderr, "SQL_CONNECT_IS_EXCLUDED %s\n", database); + slNameFree(noFoDbs); + return sc; + } +} // if the requested database exists only on the failover connection, then the main connect -// failed. We just connect again without a database, but note the database +// failed. We just connect again without a database, and store the database name if (sc==NULL) { if (monitorFlags & JKSQL_TRACE) fprintf(stderr, "SQL_CONNECT_MAIN_FAIL %s\n", database); sc = sqlConnRemote(sp, NULL, TRUE); sc->db = cloneString(database); } sc->profile = sp; // remember the profile // don't connect the failOver connection yet: lazily connect later when needed sc->failoverConn = sqlUnconnectedConn(failoverProf, database); return sc; }