mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
repmgrd: ensure PQfinish() always executed on failed connections in NodeInfoLists
clear_node_info_list() will clean up any remaining active connections, but we need to ensure all failed connections are cleaned up at the point of failure to prevent leaks. Per report in GitHub #643.
This commit is contained in:
@@ -1853,6 +1853,7 @@ monitor_streaming_standby(void)
|
||||
if (PQstatus(cell->node_info->conn) != CONNECTION_OK)
|
||||
{
|
||||
log_debug("unable to connect to %i ... ", cell->node_info->node_id);
|
||||
close_connection(&cell->node_info->conn);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2470,6 +2471,7 @@ monitor_streaming_witness(void)
|
||||
if (PQstatus(cell->node_info->conn) != CONNECTION_OK)
|
||||
{
|
||||
log_debug("unable to connect to %i ... ", cell->node_info->node_id);
|
||||
close_connection(&cell->node_info->conn);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3585,6 +3587,8 @@ notify_followers(NodeInfoList *standby_nodes, int follow_node_id)
|
||||
cell->node_info->node_name,
|
||||
cell->node_info->node_id);
|
||||
|
||||
close_connection(&cell->node_info->conn);
|
||||
|
||||
cell->node_info->conn = establish_db_connection(cell->node_info->conninfo, false);
|
||||
}
|
||||
|
||||
@@ -3595,6 +3599,7 @@ notify_followers(NodeInfoList *standby_nodes, int follow_node_id)
|
||||
cell->node_info->node_id);
|
||||
log_detail("\n%s", PQerrorMessage(cell->node_info->conn));
|
||||
|
||||
close_connection(&cell->node_info->conn);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -4189,6 +4194,7 @@ do_election(NodeInfoList *sibling_nodes, int *new_primary_id)
|
||||
|
||||
if (PQstatus(cell->node_info->conn) != CONNECTION_OK)
|
||||
{
|
||||
close_connection(&cell->node_info->conn);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user