From a38e229e611b685921a53f07bb5dcf135f652d65 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Mon, 18 Mar 2019 16:16:54 +0900 Subject: [PATCH] check_primary_status(): handle case where recovery type unknown --- repmgrd-physical.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/repmgrd-physical.c b/repmgrd-physical.c index 3c541cab..ec8c0ee2 100644 --- a/repmgrd-physical.c +++ b/repmgrd-physical.c @@ -477,9 +477,17 @@ check_primary_status(int degraded_monitoring_elapsed) PGconn *new_primary_conn; RecordStatus record_status; bool resume_monitoring = true; + RecoveryType recovery_type = get_recovery_type(local_conn); + + if (recovery_type == RECTYPE_UNKNOWN) + { + log_warning(_("unable to determine node recovery status")); + /* "true" to indicate repmgrd should continue monitoring in degraded state */ + return true; + } /* node is still primary - resume monitoring */ - if (get_recovery_type(local_conn) == RECTYPE_PRIMARY) + if (recovery_type == RECTYPE_PRIMARY) { if (degraded_monitoring_elapsed != NO_DEGRADED_MONITORING_ELAPSED) { @@ -530,7 +538,16 @@ check_primary_status(int degraded_monitoring_elapsed) if (PQstatus(new_primary_conn) != CONNECTION_OK) { close_connection(&new_primary_conn); - log_warning(_("unable to connect to new primary node %i"), primary_node_id); + + if (primary_node_id == UNKNOWN_NODE_ID) + { + log_warning(_("unable to determine a new primary node")); + } + else + { + log_warning(_("unable to connect to new primary node %i"), primary_node_id); + } + /* "true" to indicate repmgrd should continue monitoring in degraded state */ return true; }