diff --git a/dbutils.c b/dbutils.c index c1198d77..f5fbd1f2 100644 --- a/dbutils.c +++ b/dbutils.c @@ -4745,3 +4745,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"; +} diff --git a/dbutils.h b/dbutils.h index 1fbee8a7..d10d1ec5 100644 --- a/dbutils.h +++ b/dbutils.h @@ -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_ */ diff --git a/repmgr-action-node.c b/repmgr-action-node.c index fd397bad..17236db9 100644 --- a/repmgr-action-node.c +++ b/repmgr-action-node.c @@ -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; } } diff --git a/repmgr-action-standby.c b/repmgr-action-standby.c index 1c24f49d..3ad2ded3 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -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); }