mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 08:56:29 +00:00
repmgr standby switchover: add sanity check for pg_rewind useability
pg_rewind will only be executed on a demoted primary if explictly requested, to prevent transactions on the primary, which were never replicated, from being automatically overwritten. If --force-rewind is provided, we'll need to check pg_rewind is actually useable before we need to use it.
This commit is contained in:
@@ -1563,7 +1563,8 @@ do_standby_follow(void)
|
||||
* we'll need the location of its configuration file; this
|
||||
* can be provided explicitly with -C/--remote-config-file,
|
||||
* otherwise repmgr will look in default locations on the
|
||||
* remote server
|
||||
* remote server (starting with the same path as the local
|
||||
* configuration file)
|
||||
*
|
||||
* TODO:
|
||||
* - make connection test timeouts/intervals configurable (see below)
|
||||
@@ -1695,6 +1696,31 @@ do_standby_switchover(void)
|
||||
|
||||
log_verbose(LOG_DEBUG, "remote node name is \"%s\"", remote_node_record.node_name);
|
||||
|
||||
|
||||
/*
|
||||
* If --force-rewind specified, check pg_rewind can be used
|
||||
*/
|
||||
|
||||
if (runtime_options.force_rewind == true)
|
||||
{
|
||||
PQExpBufferData reason;
|
||||
|
||||
initPQExpBuffer(&reason);
|
||||
|
||||
if (can_use_pg_rewind(remote_conn, config_file_options.data_directory, &reason) == false)
|
||||
{
|
||||
log_error(_("--force-rewind specified but pg_rewind cannot be used"));
|
||||
log_detail("%s", reason.data);
|
||||
termPQExpBuffer(&reason);
|
||||
PQfinish(local_conn);
|
||||
PQfinish(remote_conn);
|
||||
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
|
||||
termPQExpBuffer(&reason);
|
||||
}
|
||||
|
||||
PQfinish(local_conn);
|
||||
PQfinish(remote_conn);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user