mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
repmgr: assume node is actually shutting down if pingable and that's the reported status
This commit is contained in:
19
dbutils.c
19
dbutils.c
@@ -4740,3 +4740,22 @@ print_node_status(NodeStatus node_status)
|
||||
|
||||
return "UNIDENTIFIED_STATUS";
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
print_pqping_status(PGPing ping_status)
|
||||
{
|
||||
switch (ping_status)
|
||||
{
|
||||
case PQPING_OK:
|
||||
return "PQPING_OK";
|
||||
case PQPING_REJECT:
|
||||
return "PQPING_REJECT";
|
||||
case PQPING_NO_RESPONSE:
|
||||
return "PQPING_NO_RESPONSE";
|
||||
case PQPING_NO_ATTEMPT:
|
||||
return "PQPING_NO_ATTEMPT";
|
||||
}
|
||||
|
||||
return "PQPING_UNKNOWN_STATUS";
|
||||
}
|
||||
|
||||
@@ -513,5 +513,6 @@ bool bdr_node_set_repmgr_set(PGconn *conn, const char *node_name);
|
||||
|
||||
/* miscellaneous debugging functions */
|
||||
const char *print_node_status(NodeStatus node_status);
|
||||
const char *print_pqping_status(PGPing ping_status);
|
||||
|
||||
#endif /* _REPMGR_DBUTILS_H_ */
|
||||
|
||||
@@ -496,26 +496,18 @@ _do_node_status_is_shutdown_cleanly(void)
|
||||
|
||||
db_state = get_db_state(config_file_options.data_directory);
|
||||
|
||||
|
||||
log_verbose(LOG_DEBUG, "db state now: %s", describe_db_state(db_state));
|
||||
|
||||
if (db_state != DB_SHUTDOWNED && db_state != DB_SHUTDOWNED_IN_RECOVERY)
|
||||
{
|
||||
|
||||
if (node_status != NODE_STATUS_UP)
|
||||
{
|
||||
if (db_state == DB_SHUTDOWNING)
|
||||
{
|
||||
node_status = NODE_STATUS_SHUTTING_DOWN;
|
||||
}
|
||||
/*
|
||||
* node is not running or shutting down, but pg_controldata says it is -
|
||||
* unclean shutdown
|
||||
*/
|
||||
else
|
||||
{
|
||||
node_status = NODE_STATUS_UNCLEAN_SHUTDOWN;
|
||||
}
|
||||
node_status = NODE_STATUS_UNCLEAN_SHUTDOWN;
|
||||
}
|
||||
/* server is still responding but shutting down */
|
||||
else if (db_state == DB_SHUTDOWNING)
|
||||
{
|
||||
node_status = NODE_STATUS_SHUTTING_DOWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2668,6 +2668,8 @@ do_standby_switchover(void)
|
||||
i + 1, config_file_options.reconnect_attempts);
|
||||
ping_res = PQping(remote_conninfo);
|
||||
|
||||
log_debug("ping status is: %s", print_pqping_status(ping_res));
|
||||
|
||||
/* database server could not be contacted */
|
||||
if (ping_res == PQPING_NO_RESPONSE || ping_res == PQPING_NO_ATTEMPT)
|
||||
{
|
||||
@@ -2732,6 +2734,7 @@ do_standby_switchover(void)
|
||||
termPQExpBuffer(&command_output);
|
||||
}
|
||||
|
||||
log_debug("sleeping %i seconds until next check", config_file_options.reconnect_interval);
|
||||
sleep(config_file_options.reconnect_interval);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user