From e32acda8c050476d4ef2bb4429ba71b5b85429c6 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Mon, 29 Apr 2019 14:30:48 +0900 Subject: [PATCH] standby switchover: ignore nodes which are unreachable and marked as inactive Previously "repmgr standby switchover" would abort if any node was unreachable, as that means it was unable to check if repmgrd is running. However if the node has been marked as inactive in the repmgr metadata, it's reasonable to assume the node is no longer part of the replication cluster and does not need to be checked. --- doc/appendix-release-notes.sgml | 10 +++++++++- repmgr-action-standby.c | 20 ++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/doc/appendix-release-notes.sgml b/doc/appendix-release-notes.sgml index 71af8999..1e39eced 100644 --- a/doc/appendix-release-notes.sgml +++ b/doc/appendix-release-notes.sgml @@ -81,9 +81,17 @@ + + + &repmgr;: when executing repmgr standby switchover, don't abort if one or more nodes are not reachable and + they are marked as inactive. + + + - + + diff --git a/repmgr-action-standby.c b/repmgr-action-standby.c index 9dbc3c72..b8fffa00 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -4086,16 +4086,24 @@ do_standby_switchover(void) repmgrd_info[i]->pg_running = false; - item_list_append_format(&repmgrd_connection_errors, - _("unable to connect to node \"%s\" (ID %i):\n%s"), - cell->node_info->node_name, - cell->node_info->node_id, - PQerrorMessage(cell->node_info->conn)); + /* + * Only worry about unreachable nodes if they're marked as active + * in the repmgr metadata. + */ + if (cell->node_info->active == true) + { + unreachable_node_count++; + + item_list_append_format(&repmgrd_connection_errors, + _("unable to connect to node \"%s\" (ID %i):\n%s"), + cell->node_info->node_name, + cell->node_info->node_id, + PQerrorMessage(cell->node_info->conn)); + } PQfinish(cell->node_info->conn); cell->node_info->conn = NULL; - unreachable_node_count++; i++; continue; }