From 93187e9743da1636a3f2da1da280eb62909cd1cf Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Tue, 1 Dec 2020 16:08:05 +0900 Subject: [PATCH] Add missing connection close In a corner-case situation where a standby is unable to attach to the new primary due to a mismatch in the WAL stream, the connection used to verify the recovery status of the new primary was not being closed, leading to a risk of connection exhaustion on the new primary. Addresses GitHub #682. --- repmgrd-physical.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/repmgrd-physical.c b/repmgrd-physical.c index ffb5d756..c685eb05 100644 --- a/repmgrd-physical.c +++ b/repmgrd-physical.c @@ -3921,6 +3921,7 @@ follow_new_primary(int new_primary_id) termPQExpBuffer(&event_details); + close_connection(&upstream_conn); close_connection(&old_primary_conn); return FAILOVER_STATE_PRIMARY_REAPPEARED; @@ -3931,6 +3932,8 @@ follow_new_primary(int new_primary_id) close_connection(&old_primary_conn); } + close_connection(&upstream_conn); + return FAILOVER_STATE_FOLLOW_FAIL; }