Commit d5d112b1 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Corresponding change for Chris; Instead of tmcd_redirect table, use a

per-experiment level DB redirect. This makes it easier to tolerate
testing harness failures.
parent 0918505d
......@@ -1713,6 +1713,8 @@ checkdbredirect(struct in_addr ipaddr)
MYSQL_RES *res;
MYSQL_ROW row;
char nodeid[32];
char pid[64];
char eid[64];
char newdb[128];
/*
......@@ -1723,23 +1725,38 @@ checkdbredirect(struct in_addr ipaddr)
inet_ntoa(ipaddr));
return 1;
}
if (nodeidtoexp(nodeid, pid, eid)) {
syslog(LOG_ERR, "CHECKDBREDIRECT: %s: Node is free", nodeid);
return 0;
}
/*
* Look for an alternate DB name.
*/
res = mydb_query("select dbname from tmcd_redirect where node_id='%s'",
1, nodeid);
res = mydb_query("select testdb from experiments "
"where eid='%s' and pid='%s'",
1, eid, pid);
if (!res) {
syslog(LOG_ERR, "CHECKDBREDIRECT: "
"%s: DB Error getting redirect table!", nodeid);
"%s: DB Error getting testdb from table!", nodeid);
return 1;
}
if ((int)mysql_num_rows(res)) {
if (mysql_num_rows(res) == 0) {
syslog(LOG_ERR, "CHECKDBREDIRECT: "
"%s: Hmm, experiment not there anymore!", nodeid);
mysql_free_result(res);
return 0;
}
row = mysql_fetch_row(res);
strcpy(dbname, row[0]);
if (!row[0] || !row[0][0]) {
mysql_free_result(res);
return 0;
}
/* This changes the DB we talk to. */
strcpy(dbname, row[0]);
/*
* Okay, lets test to make sure that DB exists. If not, fall back
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment