From 9ee244858350a032b6f5189f4d87568b34145b56 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 8798f3e4..df5737da 100644 --- a/doc/appendix-release-notes.sgml +++ b/doc/appendix-release-notes.sgml @@ -55,9 +55,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 133a46ad..094afd64 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -4084,16 +4084,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; }