From 1f8f6f3a394383f1926fffcaea994f489b6fd98c Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 27 Sep 2018 11:06:18 +0900 Subject: [PATCH] repmgrd: add notice about different location preventing standby promotion Though we note this in the DEBUG output, it's not immediately obvious from the logs, especially outside of the DEBUG log level, why a node didn't promote itself if it is in a different location to the primary. --- repmgrd-physical.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/repmgrd-physical.c b/repmgrd-physical.c index 52187c68..ec1e0682 100644 --- a/repmgrd-physical.c +++ b/repmgrd-physical.c @@ -1664,7 +1664,19 @@ do_primary_failover(void) } else if (election_result == ELECTION_LOST || election_result == ELECTION_NOT_CANDIDATE) { - log_info(_("follower node awaiting notification from the candidate node")); + /* + * if the node couldn't be promoted as it's not in the same location as the primary, + * add an explanatory notice + */ + if (election_result == ELECTION_NOT_CANDIDATE && strncmp(upstream_node_info.location, local_node_info.location, MAXLEN) != 0) + { + log_notice(_("this node's location (\"%s\") is not the primary node location (\"%s\"), so node cannot be promoted"), + local_node_info.location, + upstream_node_info.location); + } + + log_info(_("follower node awaiting notification from a candidate node")); + failover_state = FAILOVER_STATE_WAITING_NEW_PRIMARY; } @@ -2766,7 +2778,9 @@ do_election(void) total_nodes = sibling_nodes.node_count + 1; - log_debug("do_election(): primary location is %s", upstream_node_info.location); + log_debug("do_election(): primary location is \"%s\", standby location is \"%s\"", + upstream_node_info.location, + local_node_info.location); local_node_info.last_wal_receive_lsn = InvalidXLogRecPtr;