mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
node rejoin: improve error code handling
- return ERR_REJOIN_FAIL in all cases where the rejoin operation fails - ensure ERR_FOLLOW_FAIL is not returned - document error codes
This commit is contained in:
@@ -165,6 +165,7 @@
|
|||||||
Following exit codes can be emitted by <command>repmgr status check</command>
|
Following exit codes can be emitted by <command>repmgr status check</command>
|
||||||
if no individual check was specified.
|
if no individual check was specified.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<variablelist>
|
<variablelist>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
@@ -186,6 +187,7 @@
|
|||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -255,6 +255,59 @@
|
|||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>Exit codes</title>
|
||||||
|
<para>
|
||||||
|
Following exit codes can be emitted by <command>repmgr node rejoin</command>:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>SUCCESS (0)</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The node rejoin succeeded; or if <option>--dry-run</option> was provided,
|
||||||
|
no issues were detected which would prevent the node rejoin.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>ERR_BAD_CONFIG (1)</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
A configuration issue was detected which prevented &repmgr; from
|
||||||
|
continuing with the node rejoin.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>ERR_NO_RESTART (4)</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The node could not be restarted.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>ERR_REJOIN_FAIL (24)</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The node rejoin operation failed.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title>See also</title>
|
<title>See also</title>
|
||||||
<para>
|
<para>
|
||||||
|
|||||||
@@ -2174,7 +2174,7 @@ do_node_rejoin(void)
|
|||||||
log_error(_("database is still running in state \"%s\""),
|
log_error(_("database is still running in state \"%s\""),
|
||||||
describe_db_state(db_state));
|
describe_db_state(db_state));
|
||||||
log_hint(_("\"repmgr node rejoin\" cannot be executed on a running node"));
|
log_hint(_("\"repmgr node rejoin\" cannot be executed on a running node"));
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_REJOIN_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check if cleanly shut down */
|
/* check if cleanly shut down */
|
||||||
@@ -2193,7 +2193,7 @@ do_node_rejoin(void)
|
|||||||
log_detail(_("pg_rewind will not be able to run"));
|
log_detail(_("pg_rewind will not be able to run"));
|
||||||
}
|
}
|
||||||
log_hint(_("database should be restarted then shut down cleanly after crash recovery completes"));
|
log_hint(_("database should be restarted then shut down cleanly after crash recovery completes"));
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_REJOIN_FAIL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2255,7 +2255,7 @@ do_node_rejoin(void)
|
|||||||
if (can_follow == false)
|
if (can_follow == false)
|
||||||
{
|
{
|
||||||
PQfinish(upstream_conn);
|
PQfinish(upstream_conn);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_REJOIN_FAIL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2358,7 +2358,7 @@ do_node_rejoin(void)
|
|||||||
|
|
||||||
termPQExpBuffer(&command_output);
|
termPQExpBuffer(&command_output);
|
||||||
|
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_REJOIN_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
termPQExpBuffer(&command_output);
|
termPQExpBuffer(&command_output);
|
||||||
@@ -2471,6 +2471,7 @@ do_node_rejoin(void)
|
|||||||
upstream_conn,
|
upstream_conn,
|
||||||
&primary_node_record,
|
&primary_node_record,
|
||||||
&follow_output,
|
&follow_output,
|
||||||
|
ERR_REJOIN_FAIL,
|
||||||
&follow_error_code);
|
&follow_error_code);
|
||||||
|
|
||||||
if (success == false)
|
if (success == false)
|
||||||
|
|||||||
@@ -2561,6 +2561,7 @@ do_standby_follow(void)
|
|||||||
follow_target_conn,
|
follow_target_conn,
|
||||||
&follow_target_node_record,
|
&follow_target_node_record,
|
||||||
&follow_output,
|
&follow_output,
|
||||||
|
ERR_FOLLOW_FAIL,
|
||||||
&follow_error_code);
|
&follow_error_code);
|
||||||
|
|
||||||
/* unable to restart the standby */
|
/* unable to restart the standby */
|
||||||
@@ -2665,7 +2666,7 @@ do_standby_follow(void)
|
|||||||
* this function.
|
* this function.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
do_standby_follow_internal(PGconn *primary_conn, PGconn *follow_target_conn, t_node_info *follow_target_node_record, PQExpBufferData *output, int *error_code)
|
do_standby_follow_internal(PGconn *primary_conn, PGconn *follow_target_conn, t_node_info *follow_target_node_record, PQExpBufferData *output, int general_error_code, int *error_code)
|
||||||
{
|
{
|
||||||
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;
|
||||||
@@ -2691,7 +2692,7 @@ do_standby_follow_internal(PGconn *primary_conn, PGconn *follow_target_conn, t_n
|
|||||||
log_error(_("unable to retrieve record for node %i"),
|
log_error(_("unable to retrieve record for node %i"),
|
||||||
config_file_options.node_id);
|
config_file_options.node_id);
|
||||||
|
|
||||||
*error_code = ERR_FOLLOW_FAIL;
|
*error_code = ERR_BAD_CONFIG;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2818,7 +2819,7 @@ do_standby_follow_internal(PGconn *primary_conn, PGconn *follow_target_conn, t_n
|
|||||||
|
|
||||||
if (!create_recovery_file(&local_node_record, &recovery_conninfo, config_file_options.data_directory, true))
|
if (!create_recovery_file(&local_node_record, &recovery_conninfo, config_file_options.data_directory, true))
|
||||||
{
|
{
|
||||||
*error_code = ERR_FOLLOW_FAIL;
|
*error_code = general_error_code;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2969,7 +2970,6 @@ do_standby_follow_internal(PGconn *primary_conn, PGconn *follow_target_conn, t_n
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
appendPQExpBuffer(output,
|
appendPQExpBuffer(output,
|
||||||
_("node %i is now attached to node %i"),
|
_("node %i is now attached to node %i"),
|
||||||
config_file_options.node_id,
|
config_file_options.node_id,
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ extern void do_standby_switchover(void);
|
|||||||
|
|
||||||
extern void do_standby_help(void);
|
extern void do_standby_help(void);
|
||||||
|
|
||||||
extern bool do_standby_follow_internal(PGconn *primary_conn, PGconn *follow_target_conn, t_node_info *follow_target_node_record, PQExpBufferData *output, int *error_code);
|
extern bool do_standby_follow_internal(PGconn *primary_conn, PGconn *follow_target_conn, t_node_info *follow_target_node_record, PQExpBufferData *output, int general_error_code, int *error_code);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user