39795df20ecc6043b12a9a8aa9c08660a1571bd0 max Thu Oct 30 03:49:31 2025 -0700 fixing hgBlat error when using apiKey, refs #36428 diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c index a2ba48fae6a..a9eb1c5ee5f 100644 --- src/hg/lib/hdb.c +++ src/hg/lib/hdb.c @@ -56,30 +56,32 @@ #ifdef LOWELAB #define DEFAULT_PROTEINS "proteins060115" #define DEFAULT_GENOME "Pyrobaculum aerophilum" #else #define DEFAULT_PROTEINS "proteins" #define DEFAULT_GENOME "Human" #endif static struct sqlConnCache *hdbCc = NULL; /* cache for primary database connection */ static struct sqlConnCache *centralCc = NULL; static char *centralDb = NULL; static struct sqlConnCache *cartCc = NULL; /* cache for cart; normally same as centralCc */ static char *cartDb = NULL; static char *hdbTrackDb = NULL; +static char *centralProfile = "central"; + /* cached list of tables in databases. This keeps a hash of databases to * hashes of track/table name to slName list of actual table names, which * might be split. Since individual tables can be mapped to different * profiles, and this information is only available when processing trackDb, * another table is kept to determine if these need to be checked. */ static struct hash *tableList = NULL; // db to track to tables static struct hash *tableListProfChecked = NULL; // profile:db that have been check char *dbDbTable() /* Return the name of the dbDb table. */ { static char *dbDbTable = NULL; if (dbDbTable == NULL) dbDbTable = cfgOptionEnvDefault("HGDB_DBDBTABLE", @@ -780,31 +782,30 @@ } return hAllocConn(db); } void hFreeConn(struct sqlConnection **pConn) /* Put back connection for reuse. */ { if (*pConn != NULL) // don't use hdbCc if never allocated sqlConnCacheDealloc(hdbCc, pConn); } static void hCentralMkCache() /* create the central database cache, trying to connect to the * database and failing over if needed */ { -char *centralProfile = "central"; centralDb = cfgOption2(centralProfile, "db"); centralCc = sqlConnCacheNewProfile(centralProfile); sqlSetParanoid(TRUE); struct sqlConnection *conn = sqlConnCacheMayAlloc(centralCc, centralDb); if ((conn == NULL) || (cgiIsOnWeb() && !cartTablesOk(conn))) { fprintf(stderr, "hConnectCentral failed over to backupcentral " "pid=%ld\n", (long)getpid()); sqlConnCacheDealloc(centralCc, &conn); sqlConnCacheFree(¢ralCc); centralProfile = "backupcentral"; centralDb = cfgOption2(centralProfile, "db"); centralCc = sqlConnCacheNewProfile(centralProfile); conn = sqlConnCacheAlloc(centralCc, centralDb); if (!cartTablesOk(conn)) @@ -828,30 +829,31 @@ if (centralCc == NULL) hCentralMkCache(); return sqlConnCacheAlloc(centralCc, centralDb); } void hDisconnectCentral(struct sqlConnection **pConn) /* Put back connection for reuse. */ { if (*pConn != NULL) sqlConnCacheDealloc(centralCc, pConn); } struct sqlConnection *hConnectCentralNoCache() /* open an hgcentral connection, but do not use the cache. Used before the bottleneck call. */ { + char *centralDb = cfgOption2(centralProfile, "db"); struct sqlConnection *conn = sqlMayConnect(centralDb); if (conn == NULL) errAbort("Cannot connect to MariaDB database defined in hg.conf called '%s'", centralDb); return conn; } static void hCartMkCache() /* Create the cart connection cache. Defaults to the central connection * unless cart.db or cart.host are configured. */ { if ((cfgOption("cart.db") != NULL) || (cfgOption("cart.host") != NULL) || (cfgOption("cart.user") != NULL) || (cfgOption("cart.password") != NULL)) { /* use explict cart options */ cartDb = cfgOption("cart.db");