From 79e79bd5f2ab93d828b35a3521aa232e54e609a4 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Tue, 23 Oct 2018 10:51:57 +0900 Subject: [PATCH] "standby switchover": close all connections used to check repmgrd status The connections used to check repmgrd status on all nodes were not being closed if repmgrd was not running. Normally this wouldn't be a huge problem as they will go away when repmgr terminates or the PostgreSQL server restarted. However, if shutdown mode is "smart", the open connection on the demotion candidate will cause the shutdown operation to fail until repmgr times out. --- repmgr-action-standby.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/repmgr-action-standby.c b/repmgr-action-standby.c index a20f94430..ff8acf51e 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -3718,9 +3718,18 @@ do_standby_switchover(void) i++; } } - + else + { + /* close all connections - we'll reestablish later */ + for (cell = all_nodes.head; cell; cell = cell->next) + { + PQfinish(cell->node_info->conn); + cell->node_info->conn = NULL; + } + } } + /* * Sanity checks completed - prepare for the switchover */ @@ -3801,7 +3810,7 @@ do_standby_switchover(void) shutdown_command); clear_node_info_list(&sibling_nodes); - clear_node_info_list(&all_nodes); + key_value_list_free(&remote_config_files); return; @@ -4160,8 +4169,6 @@ do_standby_switchover(void) clear_node_info_list(&sibling_nodes); - - PQfinish(local_conn); /*