repmgrd: various fixed, mainly clearing status after a failover event

This commit is contained in:
Ian Barwick
2017-07-04 11:55:03 +09:00
parent 78d45ebf68
commit 618a2346e1
7 changed files with 242 additions and 49 deletions

View File

@@ -1714,6 +1714,8 @@ clear_node_info_list(NodeInfoList *nodes)
NodeInfoListCell *cell;
NodeInfoListCell *next_cell;
log_debug("clear_node_info_list() - closing open connections");
/* close any open connections */
for (cell = nodes->head; cell; cell = cell->next)
{
@@ -1724,6 +1726,8 @@ clear_node_info_list(NodeInfoList *nodes)
}
}
log_debug("clear_node_info_list() - unlinking");
cell = nodes->head;
while (cell != NULL)
@@ -1733,7 +1737,8 @@ clear_node_info_list(NodeInfoList *nodes)
pfree(cell);
cell = next_cell;
}
nodes->head = NULL;
nodes->tail = NULL;
nodes->node_count = 0;
}
@@ -2493,6 +2498,32 @@ get_new_primary(PGconn *conn, int *primary_node_id)
}
void
reset_voting_status(PGconn *conn)
{
PQExpBufferData query;
PGresult *res;
initPQExpBuffer(&query);
appendPQExpBuffer(&query,
"SELECT repmgr.reset_voting_status()");
res = PQexec(conn, query.data);
termPQExpBuffer(&query);
// COMMAND_OK?
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
{
log_error(_("unable to execute repmgr..reset_voting_status():\n %s"),
PQerrorMessage(conn));
}
PQclear(res);
return;
}
/* ============================ */
/* replication status functions */
/* ============================ */