mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 00:26:30 +00:00
Always set "connect_timeout" when pinging a PostgreSQL instance
Insert "connect_timeout=2" into the connection parameters, if not explicitly set by the user. This will prevent excessive wait time for the host operating system to report a connection timeout.
This commit is contained in:
22
dbutils.c
22
dbutils.c
@@ -3873,6 +3873,28 @@ is_server_available(const char *conninfo)
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
is_server_available_params(t_conninfo_param_list *param_list)
|
||||
{
|
||||
PGPing status = PQpingParams((const char **) param_list->keywords,
|
||||
(const char **) param_list->values,
|
||||
false);
|
||||
|
||||
/* deparsing the param_list adds overhead, so only do it if needed */
|
||||
if (log_level == LOG_DEBUG)
|
||||
{
|
||||
char *conninfo_str = param_list_to_string(param_list);
|
||||
log_verbose(LOG_DEBUG, "ping status for %s is %i", conninfo_str, (int)status);
|
||||
pfree(conninfo_str);
|
||||
}
|
||||
|
||||
if (status == PQPING_OK)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* ==================== */
|
||||
/* monitoring functions */
|
||||
/* ==================== */
|
||||
|
||||
Reference in New Issue
Block a user