mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-25 16:16:29 +00:00
node rejoin: improve handling of --config-file parameter
Fixes bug when parsing --config-file values (GitHub #442). Also improves handling in --dry-run mode, as some checks for the provided files were being skipped if --dry-run supplied, even though they are intended to work with --dry-run.
This commit is contained in:
@@ -1672,6 +1672,13 @@ parse_server_action(const char *action_name)
|
|||||||
*
|
*
|
||||||
* Note that "repmgr node rejoin" is also executed by
|
* Note that "repmgr node rejoin" is also executed by
|
||||||
* "repmgr standby switchover" after promoting the new primary.
|
* "repmgr standby switchover" after promoting the new primary.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* --dry-run
|
||||||
|
* --force-rewind[=VALUE]
|
||||||
|
* --config-files
|
||||||
|
* --config-archive-dir
|
||||||
|
* -W/--no-wait
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
do_node_rejoin(void)
|
do_node_rejoin(void)
|
||||||
@@ -1827,11 +1834,14 @@ do_node_rejoin(void)
|
|||||||
termPQExpBuffer(&msg);
|
termPQExpBuffer(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Forcibly rewind node if requested (this is mainly for use when this
|
* Forcibly rewind node if requested (this is mainly for use when this
|
||||||
* action is being executed by "repmgr standby switchover")
|
* action is being executed by "repmgr standby switchover")
|
||||||
*/
|
*/
|
||||||
if (runtime_options.force_rewind_used == true && runtime_options.dry_run == false)
|
|
||||||
|
if (runtime_options.force_rewind_used == true)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
PQExpBufferData filebuf;
|
PQExpBufferData filebuf;
|
||||||
@@ -1866,19 +1876,16 @@ do_node_rejoin(void)
|
|||||||
log_info(_("pg_rewind would now be executed"));
|
log_info(_("pg_rewind would now be executed"));
|
||||||
log_detail(_("pg_rewind command is:\n %s"),
|
log_detail(_("pg_rewind command is:\n %s"),
|
||||||
command.data);
|
command.data);
|
||||||
|
|
||||||
PQfinish(upstream_conn);
|
|
||||||
exit(SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
log_notice(_("executing pg_rewind"));
|
log_notice(_("executing pg_rewind"));
|
||||||
log_debug("pg_rewind command is:\n %s",
|
log_debug("pg_rewind command is:\n %s",
|
||||||
command.data);
|
command.data);
|
||||||
|
|
||||||
initPQExpBuffer(&command_output);
|
initPQExpBuffer(&command_output);
|
||||||
|
|
||||||
ret = local_command(
|
ret = local_command(command.data,
|
||||||
command.data,
|
|
||||||
&command_output);
|
&command_output);
|
||||||
|
|
||||||
termPQExpBuffer(&command);
|
termPQExpBuffer(&command);
|
||||||
@@ -1925,7 +1932,7 @@ do_node_rejoin(void)
|
|||||||
* - from PostgreSQL 11, this will be handled by pg_rewind, so
|
* - from PostgreSQL 11, this will be handled by pg_rewind, so
|
||||||
* we can skip this step from that version; see commit
|
* we can skip this step from that version; see commit
|
||||||
* 266b6acb312fc440c1c1a2036aa9da94916beac6
|
* 266b6acb312fc440c1c1a2036aa9da94916beac6
|
||||||
* - possibly delete contents various other directories
|
* - possibly delete contents of various other directories
|
||||||
* as per the above commit for pre-PostgreSQL 11
|
* as per the above commit for pre-PostgreSQL 11
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
@@ -1983,6 +1990,7 @@ do_node_rejoin(void)
|
|||||||
termPQExpBuffer(&slotdir_path);
|
termPQExpBuffer(&slotdir_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (runtime_options.dry_run == true)
|
if (runtime_options.dry_run == true)
|
||||||
{
|
{
|
||||||
@@ -2160,6 +2168,11 @@ _do_node_archive_config(void)
|
|||||||
termPQExpBuffer(&archive_dir);
|
termPQExpBuffer(&archive_dir);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (runtime_options.dry_run == true)
|
||||||
|
{
|
||||||
|
log_verbose(LOG_INFO, "temporary archive directory \"%s\" created", archive_dir.data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!S_ISDIR(statbuf.st_mode))
|
else if (!S_ISDIR(statbuf.st_mode))
|
||||||
{
|
{
|
||||||
@@ -2184,8 +2197,8 @@ _do_node_archive_config(void)
|
|||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* attempt to remove any existing files in the directory TODO: collate
|
* attempt to remove any existing files in the directory
|
||||||
* problem files into list
|
* TODO: collate problem files into list
|
||||||
*/
|
*/
|
||||||
while ((arcdir_ent = readdir(arcdir)) != NULL)
|
while ((arcdir_ent = readdir(arcdir)) != NULL)
|
||||||
{
|
{
|
||||||
@@ -2261,7 +2274,11 @@ _do_node_archive_config(void)
|
|||||||
|
|
||||||
if (i < config_file_len)
|
if (i < config_file_len)
|
||||||
{
|
{
|
||||||
strncpy(filenamebuf, runtime_options.config_files + i, config_file_len - i);
|
int filename_len = config_file_len - i;
|
||||||
|
|
||||||
|
strncpy(filenamebuf, runtime_options.config_files + i, filename_len);
|
||||||
|
|
||||||
|
filenamebuf[filename_len] = '\0';
|
||||||
|
|
||||||
initPQExpBuffer(&pathbuf);
|
initPQExpBuffer(&pathbuf);
|
||||||
appendPQExpBuffer(&pathbuf,
|
appendPQExpBuffer(&pathbuf,
|
||||||
@@ -2339,7 +2356,7 @@ _do_node_archive_config(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log_verbose(LOG_INFO, "directory \"%s\" deleted", archive_dir.data);
|
log_verbose(LOG_INFO, "temporary archive directory \"%s\" deleted", archive_dir.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user