mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 00:46:29 +00:00
repmgrd: ensure primary connection is reset if same as upstream
Addresses GitHub #633.
This commit is contained in:
17
repmgrd.c
17
repmgrd.c
@@ -808,12 +808,11 @@ show_help(void)
|
||||
|
||||
|
||||
bool
|
||||
check_upstream_connection(PGconn **conn, const char *conninfo)
|
||||
check_upstream_connection(PGconn **conn, const char *conninfo, PGconn **paired_conn)
|
||||
{
|
||||
/* Check the connection status twice in case it changes after reset */
|
||||
bool twice = false;
|
||||
|
||||
|
||||
log_debug("connection check type is \"%s\"",
|
||||
print_connection_check_type(config_file_options.connection_check_type));
|
||||
/*
|
||||
@@ -862,7 +861,15 @@ check_upstream_connection(PGconn **conn, const char *conninfo)
|
||||
*conn = PQconnectdb(conninfo);
|
||||
|
||||
if (PQstatus(*conn) == CONNECTION_OK)
|
||||
{
|
||||
if (paired_conn != NULL)
|
||||
{
|
||||
log_debug("resetting paired connection");
|
||||
*paired_conn = *conn;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -913,6 +920,12 @@ check_upstream_connection(PGconn **conn, const char *conninfo)
|
||||
}
|
||||
}
|
||||
|
||||
if (paired_conn != NULL)
|
||||
{
|
||||
log_debug("resetting paired connection");
|
||||
*paired_conn = *conn;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user