repmgr: assume node is actually shutting down if pingable and that's the reported status

This commit is contained in:
Ian Barwick
2018-01-12 21:53:37 +09:00
parent 7ccae6c2b1
commit 8fd0c4ad83
4 changed files with 29 additions and 14 deletions

View File

@@ -4740,3 +4740,22 @@ print_node_status(NodeStatus node_status)
return "UNIDENTIFIED_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";
}

View File

@@ -513,5 +513,6 @@ bool bdr_node_set_repmgr_set(PGconn *conn, const char *node_name);
/* miscellaneous debugging functions */ /* miscellaneous debugging functions */
const char *print_node_status(NodeStatus node_status); const char *print_node_status(NodeStatus node_status);
const char *print_pqping_status(PGPing ping_status);
#endif /* _REPMGR_DBUTILS_H_ */ #endif /* _REPMGR_DBUTILS_H_ */

View File

@@ -496,26 +496,18 @@ _do_node_status_is_shutdown_cleanly(void)
db_state = get_db_state(config_file_options.data_directory); db_state = get_db_state(config_file_options.data_directory);
log_verbose(LOG_DEBUG, "db state now: %s", describe_db_state(db_state)); 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 (db_state != DB_SHUTDOWNED && db_state != DB_SHUTDOWNED_IN_RECOVERY)
{ {
if (node_status != NODE_STATUS_UP) if (node_status != NODE_STATUS_UP)
{ {
if (db_state == DB_SHUTDOWNING) node_status = NODE_STATUS_UNCLEAN_SHUTDOWN;
{ }
node_status = NODE_STATUS_SHUTTING_DOWN; /* server is still responding but shutting down */
} else if (db_state == DB_SHUTDOWNING)
/* {
* node is not running or shutting down, but pg_controldata says it is - node_status = NODE_STATUS_SHUTTING_DOWN;
* unclean shutdown
*/
else
{
node_status = NODE_STATUS_UNCLEAN_SHUTDOWN;
}
} }
} }

View File

@@ -2668,6 +2668,8 @@ do_standby_switchover(void)
i + 1, config_file_options.reconnect_attempts); i + 1, config_file_options.reconnect_attempts);
ping_res = PQping(remote_conninfo); ping_res = PQping(remote_conninfo);
log_debug("ping status is: %s", print_pqping_status(ping_res));
/* database server could not be contacted */ /* database server could not be contacted */
if (ping_res == PQPING_NO_RESPONSE || ping_res == PQPING_NO_ATTEMPT) if (ping_res == PQPING_NO_RESPONSE || ping_res == PQPING_NO_ATTEMPT)
{ {
@@ -2732,6 +2734,7 @@ do_standby_switchover(void)
termPQExpBuffer(&command_output); termPQExpBuffer(&command_output);
} }
log_debug("sleeping %i seconds until next check", config_file_options.reconnect_interval);
sleep(config_file_options.reconnect_interval); sleep(config_file_options.reconnect_interval);
} }