Use "rejoin target" instead of "follow target" in "node rejoin" log output

This commit is contained in:
Ian Barwick
2019-01-31 11:32:38 +09:00
parent b34c331eba
commit ea54aaa290
2 changed files with 39 additions and 30 deletions

View File

@@ -257,11 +257,11 @@
<programlisting>
$ repmgr node rejoin -f /etc/repmgr.conf -d 'host=node3 dbname=repmgr user=repmgr' \
--force-rewind --config-files=postgresql.local.conf,postgresql.conf --verbose --dry-run
INFO: replication connection to the follow target node was successful
INFO: local and follow target system identifiers match
INFO: replication connection to the rejoin target node was successful
INFO: local and rejoin target system identifiers match
DETAIL: system identifier is 6652184002263212600
ERROR: this node cannot attach to follow target node 3
DETAIL: follow target server's timeline 2 forked off current database system timeline 1 before current recovery point 0/610D710
ERROR: this node cannot attach to rejoin target node 3
DETAIL: rejoin target server's timeline 2 forked off current database system timeline 1 before current recovery point 0/610D710
HINT: use --force-rewind to execute pg_rewind</programlisting>
Here, <literal>node3</literal> was promoted to a primary while the local node was
@@ -297,11 +297,11 @@
<programlisting>
$ repmgr node rejoin -f /etc/repmgr.conf -d 'host=node3 dbname=repmgr user=repmgr' \
--config-files=postgresql.local.conf,postgresql.conf --verbose --force-rewind --dry-run
INFO: replication connection to the follow target node was successful
INFO: local and follow target system identifiers match
INFO: replication connection to the rejoin target node was successful
INFO: local and rejoin target system identifiers match
DETAIL: system identifier is 6652460429293670710
NOTICE: pg_rewind execution required for this node to attach to follow target node 3
DETAIL: follow target server's timeline 2 forked off current database system timeline 1 before current recovery point 0/610D710
NOTICE: pg_rewind execution required for this node to attach to rejoin target node 3
DETAIL: rejoin target server's timeline 2 forked off current database system timeline 1 before current recovery point 0/610D710
INFO: prerequisites for using pg_rewind are met
INFO: file "postgresql.local.conf" would be copied to "/tmp/repmgr-config-archive-node2/postgresql.local.conf"
INFO: file "postgresql.replication-setup.conf" would be copied to "/tmp/repmgr-config-archive-node2/postgresql.replication-setup.conf"
@@ -322,8 +322,8 @@
<programlisting>
$ repmgr node rejoin -f /etc/repmgr.conf -d 'host=node3 dbname=repmgr user=repmgr' \
--config-files=postgresql.local.conf,postgresql.conf --verbose --force-rewind
NOTICE: pg_rewind execution required for this node to attach to follow target node 3
DETAIL: follow target server's timeline 2 forked off current database system timeline 1 before current recovery point 0/610D710
NOTICE: pg_rewind execution required for this node to attach to rejoin target node 3
DETAIL: rejoin target server's timeline 2 forked off current database system timeline 1 before current recovery point 0/610D710
NOTICE: executing pg_rewind
DETAIL: pg_rewind command is "pg_rewind -D '/var/lib/postgresql/data' --source-server='host=node3 dbname=repmgr user=repmgr'"
NOTICE: 2 files copied to /var/lib/postgresql/data

View File

@@ -3233,6 +3233,8 @@ check_node_can_attach(TimeLineID local_tli, XLogRecPtr local_xlogpos, PGconn *fo
TimeLineHistoryEntry *follow_target_history = NULL;
bool success = true;
const char *action = is_rejoin == true ? "rejoin" : "follow";
/* check replication connection */
initialize_conninfo_params(&follow_target_repl_conninfo, false);
@@ -3252,18 +3254,18 @@ check_node_can_attach(TimeLineID local_tli, XLogRecPtr local_xlogpos, PGconn *fo
if (PQstatus(follow_target_repl_conn) != CONNECTION_OK)
{
log_error(_("unable to establish a replication connection to the follow target node"));
log_error(_("unable to establish a replication connection to the %s target node"), action);
return false;
}
else if (runtime_options.dry_run == true)
{
log_info(_("replication connection to the follow target node was successful"));
log_info(_("replication connection to the %s target node was successful"), action);
}
/* check system_identifiers match */
if (identify_system(follow_target_repl_conn, &follow_target_identification) == false)
{
log_error(_("unable to query the follow target node's system identification"));
log_error(_("unable to query the %s target node's system identification"), action);
PQfinish(follow_target_repl_conn);
return false;
@@ -3276,9 +3278,10 @@ check_node_can_attach(TimeLineID local_tli, XLogRecPtr local_xlogpos, PGconn *fo
*/
if (follow_target_identification.system_identifier != local_system_identifier)
{
log_error(_("this node is not part of the follow target node's replication cluster"));
log_detail(_("this node's system identifier is %lu, follow target node's system identifier is %lu"),
log_error(_("this node is not part of the %s target node's replication cluster"), action);
log_detail(_("this node's system identifier is %lu, %s target node's system identifier is %lu"),
local_system_identifier,
action,
follow_target_identification.system_identifier);
PQfinish(follow_target_repl_conn);
return false;
@@ -3286,22 +3289,24 @@ check_node_can_attach(TimeLineID local_tli, XLogRecPtr local_xlogpos, PGconn *fo
if (runtime_options.dry_run == true)
{
log_info(_("local and follow target system identifiers match"));
log_info(_("local and %s target system identifiers match"), action);
log_detail(_("system identifier is %lu"), local_system_identifier);
}
/* check timelines */
log_verbose(LOG_DEBUG, "local timeline: %i; follow target timeline: %i",
log_verbose(LOG_DEBUG, "local timeline: %i; %s target timeline: %i",
local_tli,
action,
follow_target_identification.timeline);
/* upstream's timeline is lower than ours - impossible case */
if (follow_target_identification.timeline < local_tli)
{
log_error(_("this node's timeline is ahead of the follow target node's timeline"));
log_detail(_("this node's timeline is %i, follow target node's timeline is %i"),
log_error(_("this node's timeline is ahead of the %s target node's timeline"), action);
log_detail(_("this node's timeline is %i, %s target node's timeline is %i"),
local_tli,
action,
follow_target_identification.timeline);
PQfinish(follow_target_repl_conn);
return false;
@@ -3322,17 +3327,17 @@ check_node_can_attach(TimeLineID local_tli, XLogRecPtr local_xlogpos, PGconn *fo
if (local_xlogpos <= follow_target_xlogpos)
{
log_info(_("timelines are same, this server is not ahead"));
log_detail(_("local node lsn is %X/%X, follow target lsn is %X/%X"),
log_detail(_("local node lsn is %X/%X, %s target lsn is %X/%X"),
format_lsn(local_xlogpos),
action,
format_lsn(follow_target_xlogpos));
}
else
{
const char *error_msg = _("this node is ahead of the follow target");
log_error("%s", error_msg);
log_detail(_("local node lsn is %X/%X, follow target lsn is %X/%X"),
log_error(_("this node is ahead of the %s target"), action);
log_detail(_("local node lsn is %X/%X, %s target lsn is %X/%X"),
format_lsn(local_xlogpos),
action,
format_lsn(follow_target_xlogpos));
success = false;
@@ -3363,17 +3368,19 @@ check_node_can_attach(TimeLineID local_tli, XLogRecPtr local_xlogpos, PGconn *fo
{
if (is_rejoin == true && runtime_options.force_rewind_used == true)
{
log_notice(_("pg_rewind execution required for this node to attach to follow target node %i"),
follow_target_node_record->node_id);
log_notice(_("pg_rewind execution required for this node to attach to rejoin target node %i"),
follow_target_node_record->node_id);
}
else
{
log_error(_("this node cannot attach to follow target node %i"),
log_error(_("this node cannot attach to %s target node %i"),
action,
follow_target_node_record->node_id);
success = false;
}
log_detail(_("follow target server's timeline %i forked off current database system timeline %i before current recovery point %X/%X"),
log_detail(_("%s target server's timeline %i forked off current database system timeline %i before current recovery point %X/%X"),
action,
local_tli + 1,
local_tli,
format_lsn(local_xlogpos));
@@ -3388,12 +3395,14 @@ check_node_can_attach(TimeLineID local_tli, XLogRecPtr local_xlogpos, PGconn *fo
{
if (is_rejoin == false || (is_rejoin == true && runtime_options.force_rewind_used == false))
{
log_info(_("local node %i can attach to target node %i"),
log_info(_("local node %i can attach to %s target node %i"),
config_file_options.node_id,
action,
follow_target_node_record->node_id);
log_detail(_("local node's recovery point: %X/%X; follow target node's fork point: %X/%X"),
log_detail(_("local node's recovery point: %X/%X; %s target node's fork point: %X/%X"),
format_lsn(local_xlogpos),
action,
format_lsn(follow_target_history->end));
}
}