mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 08:36:30 +00:00
"standby follow": initial implementation of --dry-run option
GitHub #363.
This commit is contained in:
@@ -48,6 +48,32 @@
|
|||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>Options</title>
|
||||||
|
<variablelist>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>--dry-run</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Check prerequisites but don't actually follow a new standby.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-W</option></term>
|
||||||
|
<term><option>--wait</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Wait for a primary to appear.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
</variablelist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title>Event notifications</title>
|
<title>Event notifications</title>
|
||||||
<para>
|
<para>
|
||||||
|
|||||||
@@ -1647,6 +1647,15 @@ do_standby_follow(void)
|
|||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (runtime_options.dry_run == true)
|
||||||
|
{
|
||||||
|
log_info(_("connected to node %i, checking for current primary"), primary_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log_verbose(LOG_INFO, _("connected to node %i, checking for current primary"), primary_id);
|
||||||
|
}
|
||||||
|
|
||||||
record_status = get_node_record(primary_conn, primary_id, &primary_node_record);
|
record_status = get_node_record(primary_conn, primary_id, &primary_node_record);
|
||||||
|
|
||||||
if (record_status != RECORD_FOUND)
|
if (record_status != RECORD_FOUND)
|
||||||
@@ -1657,6 +1666,19 @@ do_standby_follow(void)
|
|||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (runtime_options.dry_run == true)
|
||||||
|
{
|
||||||
|
log_info(_("primary node is \"%s\" (ID: %i)"),
|
||||||
|
primary_node_record.node_name,
|
||||||
|
primary_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log_verbose(LOG_INFO, ("primary node is \"%s\" (ID: %i)"),
|
||||||
|
primary_node_record.node_name,
|
||||||
|
primary_id);
|
||||||
|
}
|
||||||
|
|
||||||
/* XXX check this is not current upstream anyway */
|
/* XXX check this is not current upstream anyway */
|
||||||
/* check replication connection */
|
/* check replication connection */
|
||||||
initialize_conninfo_params(&repl_conninfo, false);
|
initialize_conninfo_params(&repl_conninfo, false);
|
||||||
@@ -1673,6 +1695,10 @@ do_standby_follow(void)
|
|||||||
PQfinish(primary_conn);
|
PQfinish(primary_conn);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
else if (runtime_options.dry_run == true)
|
||||||
|
{
|
||||||
|
log_info(_("replication connection to primary node was successful"));
|
||||||
|
}
|
||||||
|
|
||||||
/* check system_identifiers match */
|
/* check system_identifiers match */
|
||||||
local_system_identifier = get_system_identifier(config_file_options.data_directory);
|
local_system_identifier = get_system_identifier(config_file_options.data_directory);
|
||||||
@@ -1696,10 +1722,24 @@ do_standby_follow(void)
|
|||||||
PQfinish(repl_conn);
|
PQfinish(repl_conn);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
else if (runtime_options.dry_run == true)
|
||||||
|
{
|
||||||
|
log_info(_("local and primary system identifiers match"));
|
||||||
|
log_detail(_("system identifier is %lu"), local_system_identifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TODO: check timelines*/
|
||||||
|
|
||||||
PQfinish(repl_conn);
|
PQfinish(repl_conn);
|
||||||
free_conninfo_params(&repl_conninfo);
|
free_conninfo_params(&repl_conninfo);
|
||||||
|
|
||||||
|
if (runtime_options.dry_run == true)
|
||||||
|
{
|
||||||
|
log_info(_("prerequisites for executing STANDBY FOLLOW are met"));
|
||||||
|
exit(SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
initPQExpBuffer(&follow_output);
|
initPQExpBuffer(&follow_output);
|
||||||
|
|
||||||
success = do_standby_follow_internal(primary_conn,
|
success = do_standby_follow_internal(primary_conn,
|
||||||
@@ -5426,6 +5466,7 @@ do_standby_help(void)
|
|||||||
puts("");
|
puts("");
|
||||||
printf(_(" \"standby follow\" instructs a standby node to follow a new primary.\n"));
|
printf(_(" \"standby follow\" instructs a standby node to follow a new primary.\n"));
|
||||||
puts("");
|
puts("");
|
||||||
|
printf(_(" --dry-run perform checks but don't actually follow the new primary\n"));
|
||||||
printf(_(" -W, --wait wait for a primary to appear\n"));
|
printf(_(" -W, --wait wait for a primary to appear\n"));
|
||||||
puts("");
|
puts("");
|
||||||
|
|
||||||
|
|||||||
@@ -1579,8 +1579,7 @@ check_cli_parameters(const int action)
|
|||||||
case NODE_STATUS:
|
case NODE_STATUS:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
item_list_append_format(
|
item_list_append_format(&cli_warnings,
|
||||||
&cli_warnings,
|
|
||||||
_("--is-shutdown-cleanly will be ignored when executing %s"),
|
_("--is-shutdown-cleanly will be ignored when executing %s"),
|
||||||
action_name(action));
|
action_name(action));
|
||||||
}
|
}
|
||||||
@@ -1593,8 +1592,7 @@ check_cli_parameters(const int action)
|
|||||||
case STANDBY_SWITCHOVER:
|
case STANDBY_SWITCHOVER:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
item_list_append_format(
|
item_list_append_format(&cli_warnings,
|
||||||
&cli_warnings,
|
|
||||||
_("--always-promote will be ignored when executing %s"),
|
_("--always-promote will be ignored when executing %s"),
|
||||||
action_name(action));
|
action_name(action));
|
||||||
}
|
}
|
||||||
@@ -1608,8 +1606,7 @@ check_cli_parameters(const int action)
|
|||||||
case NODE_REJOIN:
|
case NODE_REJOIN:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
item_list_append_format(
|
item_list_append_format(&cli_warnings,
|
||||||
&cli_warnings,
|
|
||||||
_("--force-rewind will be ignored when executing %s"),
|
_("--force-rewind will be ignored when executing %s"),
|
||||||
action_name(action));
|
action_name(action));
|
||||||
}
|
}
|
||||||
@@ -1623,8 +1620,7 @@ check_cli_parameters(const int action)
|
|||||||
case NODE_REJOIN:
|
case NODE_REJOIN:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
item_list_append_format(
|
item_list_append_format(&cli_warnings,
|
||||||
&cli_warnings,
|
|
||||||
_("--config-files will be ignored when executing %s"),
|
_("--config-files will be ignored when executing %s"),
|
||||||
action_name(action));
|
action_name(action));
|
||||||
}
|
}
|
||||||
@@ -1638,6 +1634,7 @@ check_cli_parameters(const int action)
|
|||||||
case PRIMARY_UNREGISTER:
|
case PRIMARY_UNREGISTER:
|
||||||
case STANDBY_CLONE:
|
case STANDBY_CLONE:
|
||||||
case STANDBY_REGISTER:
|
case STANDBY_REGISTER:
|
||||||
|
case STANDBY_FOLLOW:
|
||||||
case STANDBY_SWITCHOVER:
|
case STANDBY_SWITCHOVER:
|
||||||
case WITNESS_REGISTER:
|
case WITNESS_REGISTER:
|
||||||
case WITNESS_UNREGISTER:
|
case WITNESS_UNREGISTER:
|
||||||
@@ -1645,8 +1642,7 @@ check_cli_parameters(const int action)
|
|||||||
case NODE_SERVICE:
|
case NODE_SERVICE:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
item_list_append_format(
|
item_list_append_format(&cli_warnings,
|
||||||
&cli_warnings,
|
|
||||||
_("--dry-run is not effective when executing %s"),
|
_("--dry-run is not effective when executing %s"),
|
||||||
action_name(action));
|
action_name(action));
|
||||||
}
|
}
|
||||||
@@ -1668,8 +1664,7 @@ check_cli_parameters(const int action)
|
|||||||
if (used_options > 1)
|
if (used_options > 1)
|
||||||
{
|
{
|
||||||
/* TODO: list which options were used */
|
/* TODO: list which options were used */
|
||||||
item_list_append(
|
item_list_append(&cli_errors,
|
||||||
&cli_errors,
|
|
||||||
"only one of --csv, --nagios and --optformat can be used");
|
"only one of --csv, --nagios and --optformat can be used");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user