Have do_standby_follow_internal() not abort on error

Pass the error code back to the caller instead, mainly so
"repmgr node rejoin" can better report errors.
This commit is contained in:
Ian Barwick
2018-01-30 16:53:04 +09:00
parent 044d8a1098
commit 92f4710ee2
5 changed files with 49 additions and 20 deletions

View File

@@ -1590,6 +1590,7 @@ do_node_rejoin(void)
bool success = true;
int server_version_num = UNKNOWN_SERVER_VERSION_NUM;
int follow_error_code = SUCCESS;
/* check node is not actually running */
@@ -1859,7 +1860,31 @@ do_node_rejoin(void)
success = do_standby_follow_internal(upstream_conn,
&primary_node_record,
&follow_output);
&follow_output,
&follow_error_code);
if (success == false)
{
log_notice(_("NODE REJOIN failed"));
log_detail("%s", follow_output.data);
create_event_notification(upstream_conn,
&config_file_options,
config_file_options.node_id,
"node_rejoin",
success,
follow_output.data);
PQfinish(upstream_conn);
termPQExpBuffer(&follow_output);
exit(follow_error_code);
}
/*
* XXX add checks that node actually started and connected to primary,
* if not exit with ERR_REJOIN_FAIL
*/
create_event_notification(upstream_conn,
&config_file_options,
@@ -1870,19 +1895,12 @@ do_node_rejoin(void)
PQfinish(upstream_conn);
if (success == false)
{
log_notice(_("NODE REJOIN failed"));
log_detail("%s", follow_output.data);
termPQExpBuffer(&follow_output);
exit(ERR_DB_QUERY);
}
log_notice(_("NODE REJOIN successful"));
log_detail("%s", follow_output.data);
termPQExpBuffer(&follow_output);
return;
}