Teach witness repmgrd to deal with the absence of a primary

Previously it would refuse to start if the primary was not reachable,
the thinking being that it's pointless trying to monitor an incomplete
cluster.

However following an aborted failover situation, repmgrd will restart
monitoring and on the witness server, this will lead to it aborting
itself due to to continuing absence of primary.

To resolve this, witness repmgrd will now start monitoring in degraded
mode if no primary is found in the hope a primary will reappear at
some point.
This commit is contained in:
Ian Barwick
2018-11-29 11:56:09 +09:00
parent bdcc4d9e83
commit a6a2be2239
3 changed files with 73 additions and 40 deletions

View File

@@ -4709,6 +4709,13 @@ get_new_primary(PGconn *conn, int *primary_node_id)
PQclear(res);
/*
* repmgr.get_new_primary() will return UNKNOWN_NODE_ID if
* "follow_new_primary" is false
*/
if (new_primary_node_id == UNKNOWN_NODE_ID)
success = false;
*primary_node_id = new_primary_node_id;
return success;