Speed up witness "failover" during a switchover

This commit is contained in:
Ian Barwick
2018-10-18 17:26:29 +09:00
parent 62ac56c3f5
commit 36bd7cdc9f

View File

@@ -4087,9 +4087,25 @@ do_standby_switchover(void)
if (sibling_node_record.type == WITNESS)
{
/* TODO: create "repmgr witness resync" or similar */
appendPQExpBuffer(&remote_command_str,
"witness register -d \\'%s\\' --force 2>/dev/null && echo \"1\" || echo \"0\"",
local_node_record.conninfo);
/*
* Notify the witness repmgrd about the new primary, as at this point it will be assuming
* a failover situation is in place. It will detect the new primary at some point, this
* just speeds up the process.
*
* In the unlikely event repmgrd is not running or not in use, this will have no effect.
*/
cell->node_info->conn = establish_db_connection_quiet(cell->node_info->conninfo);
if (PQstatus(cell->node_info->conn) == CONNECTION_OK)
{
notify_follow_primary(cell->node_info->conn, local_node_record.node_id);
}
PQfinish(cell->node_info->conn);
}
else
{