src/hg/lib/hdb.c 1.402
1.402 2009/04/29 22:27:07 markd
fixed bug where wrong profile was used for hgcentral
Index: src/hg/lib/hdb.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/hdb.c,v
retrieving revision 1.401
retrieving revision 1.402
diff -b -B -U 4 -r1.401 -r1.402
--- src/hg/lib/hdb.c 17 Apr 2009 19:25:26 -0000 1.401
+++ src/hg/lib/hdb.c 29 Apr 2009 22:27:07 -0000 1.402
@@ -557,27 +557,32 @@
static void hCentralMkCache()
/* create the central database cache, trying to connect to the
* database and failing over if needed */
{
-centralDb = cfgOption2("central", "db");
-centralCc = sqlConnCacheNewProfile("central");
+char *centralProfile = "central";
+centralDb = cfgOption2(centralProfile, "db");
+centralCc = sqlConnCacheNewProfile(centralProfile);
sqlSetParanoid(TRUE);
struct sqlConnection *conn = sqlConnCacheMayAlloc(centralCc, centralDb);
if ((conn == NULL) || !cartTablesOk(conn))
{
fprintf(stderr, "ASH: hConnectCentral failed over to backupcentral! "
"pid=%ld\n", (long)getpid());
sqlConnCacheDealloc(centralCc, &conn);
sqlConnCacheFree(¢ralCc);
- centralDb = cfgOption2("backupcentral", "database");
- centralCc = sqlConnCacheNewProfile("backupcentral");
+ centralProfile = "backupcentral";
+ centralDb = cfgOption2(centralProfile, "database");
+ centralCc = sqlConnCacheNewProfile(centralProfile);
conn = sqlConnCacheAlloc(centralCc, centralDb);
if (!cartTablesOk(conn))
errAbort("Cannot access cart tables in central (nor backupcentral) "
"database. Please check central and backupcentral "
"settings in the hg.conf file and the databases they "
"specify.");
}
+/* now that a profile has been determined, make sure this database goes
+ * through that profile */
+sqlProfileAddDb(centralProfile, centralDb);
sqlConnCacheDealloc(centralCc, &conn);
sqlSetParanoid(FALSE);
}
@@ -601,19 +606,24 @@
static void hArchiveCentralMkCache()
/* create the archive central database cache, trying to connect to the
* database and failing over if needed */
{
-centralArchiveDb = cfgOption2("archivecentral", "db");
-centralArchiveCc = sqlConnCacheNewProfile("archivecentral");
+char *archiveProfile = "archivecentral";
+centralArchiveDb = cfgOption2(archiveProfile, "db");
+centralArchiveCc = sqlConnCacheNewProfile(archiveProfile);
struct sqlConnection *conn = sqlConnCacheMayAlloc(centralArchiveCc, centralArchiveDb);
if (conn == NULL)
{
sqlConnCacheDealloc(centralArchiveCc, &conn);
sqlConnCacheFree(¢ralArchiveCc);
- centralDb = cfgOption2("archivebackup", "database");
- centralCc = sqlConnCacheNewProfile("archivebackup");
+ archiveProfile = "archivebackup";
+ centralDb = cfgOption2(archiveProfile, "database");
+ centralCc = sqlConnCacheNewProfile(archiveProfile);
conn = sqlConnCacheAlloc(centralCc, centralDb);
}
+/* now that a profile has been determined, make sure this database goes
+ * through that profile */
+sqlProfileAddDb(archiveProfile, centralArchiveDb);
sqlConnCacheDealloc(centralCc, &conn);
}
struct sqlConnection *hConnectArchiveCentral()
@@ -644,8 +654,10 @@
if ((cartDb == NULL) || (cfgOption("cart.host") == NULL)
|| (cfgOption("cart.user") == NULL) || (cfgOption("cart.password") == NULL))
errAbort("Must specify either all or none of the cart options in the hg.conf file.");
cartCc = sqlConnCacheNewProfile("cart");
+ /* make sure this database goes through that profile */
+ sqlProfileAddDb("cart", cartDb);
}
else
{
/* use centralCc */