mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 17:06:29 +00:00
When performing a follow operation, start/restart server as appropriate
Before this we were always forcing a restart, which is technically not a problem but produces some potentially confusing log entries along the lines: pg_ctl: PID file "/path/to/postmaster.pid" does not exist Is server running? starting server anyway
This commit is contained in:
@@ -1390,7 +1390,6 @@ do_standby_follow_internal(PGconn *primary_conn, t_node_info *primary_node_recor
|
|||||||
{
|
{
|
||||||
t_node_info local_node_record = T_NODE_INFO_INITIALIZER;
|
t_node_info local_node_record = T_NODE_INFO_INITIALIZER;
|
||||||
int original_upstream_node_id = UNKNOWN_NODE_ID;
|
int original_upstream_node_id = UNKNOWN_NODE_ID;
|
||||||
char restart_command[MAXLEN] = "";
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
RecordStatus record_status = RECORD_NOT_FOUND;
|
RecordStatus record_status = RECORD_NOT_FOUND;
|
||||||
@@ -1494,22 +1493,40 @@ do_standby_follow_internal(PGconn *primary_conn, t_node_info *primary_node_recor
|
|||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* restart the service */
|
/* start/restart the service */
|
||||||
|
|
||||||
// XXX here check if service is running!! if not, start
|
// XXX here check if service is running!! if not, start
|
||||||
// ensure that problem with pg_ctl output is caught here
|
// ensure that problem with pg_ctl output is caught here
|
||||||
|
|
||||||
get_server_action(ACTION_RESTART, restart_command, config_file_options.data_directory);
|
|
||||||
|
|
||||||
log_notice(_("restarting server using \"%s\""),
|
|
||||||
restart_command);
|
|
||||||
|
|
||||||
r = system(restart_command);
|
|
||||||
if (r != 0)
|
|
||||||
{
|
{
|
||||||
log_error(_("unable to restart server"));
|
char server_command[MAXLEN] = "";
|
||||||
PQfinish(primary_conn);
|
bool server_up = is_server_available(config_file_options.conninfo);
|
||||||
exit(ERR_NO_RESTART);
|
char *action = NULL;
|
||||||
|
|
||||||
|
log_debug("XXX %s\n", config_file_options.conninfo);
|
||||||
|
if (server_up == true)
|
||||||
|
{
|
||||||
|
action = "restart";
|
||||||
|
get_server_action(ACTION_RESTART, server_command, config_file_options.data_directory);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
action = "start";
|
||||||
|
get_server_action(ACTION_START, server_command, config_file_options.data_directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if translation needed, generate messages in the preceding if/else */
|
||||||
|
log_notice(_("%sing server using \"%s\""),
|
||||||
|
action,
|
||||||
|
server_command);
|
||||||
|
|
||||||
|
r = system(server_command);
|
||||||
|
if (r != 0)
|
||||||
|
{
|
||||||
|
log_error(_("unable to %s server"), action);
|
||||||
|
PQfinish(primary_conn);
|
||||||
|
exit(ERR_NO_RESTART);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2381,7 +2398,7 @@ do_standby_switchover(void)
|
|||||||
* new standby
|
* new standby
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (runtime_options.siblings_follow == true)
|
if (runtime_options.siblings_follow == true && sibling_nodes.node_count > 0)
|
||||||
{
|
{
|
||||||
int failed_follow_count = 0;
|
int failed_follow_count = 0;
|
||||||
char host[MAXLEN] = "";
|
char host[MAXLEN] = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user