mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-25 08:06:29 +00:00
standby switchover: fix behaviour if witness node is a sibling
The witness node is not a streaming replication standby, so executing "repmgr standby follow" will fail. Instead, execute "repmgr witness register --force" to update the witness node record on the primary and its local copy of all node records. Addresses GitHub #453.
This commit is contained in:
@@ -3433,8 +3433,6 @@ do_standby_switchover(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check there are sufficient free walsenders - obviously there's potential
|
* check there are sufficient free walsenders - obviously there's potential
|
||||||
* for a later race condition if some walsenders come into use before the
|
* for a later race condition if some walsenders come into use before the
|
||||||
@@ -3858,7 +3856,6 @@ do_standby_switchover(void)
|
|||||||
* If --siblings-follow specified, attempt to make them follow the new
|
* If --siblings-follow specified, attempt to make them follow the new
|
||||||
* primary
|
* primary
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (runtime_options.siblings_follow == true && sibling_nodes.node_count > 0)
|
if (runtime_options.siblings_follow == true && sibling_nodes.node_count > 0)
|
||||||
{
|
{
|
||||||
int failed_follow_count = 0;
|
int failed_follow_count = 0;
|
||||||
@@ -3885,8 +3882,17 @@ do_standby_switchover(void)
|
|||||||
initPQExpBuffer(&remote_command_str);
|
initPQExpBuffer(&remote_command_str);
|
||||||
make_remote_repmgr_path(&remote_command_str, &sibling_node_record);
|
make_remote_repmgr_path(&remote_command_str, &sibling_node_record);
|
||||||
|
|
||||||
appendPQExpBuffer(&remote_command_str,
|
if (sibling_node_record.type == WITNESS)
|
||||||
"standby follow 2>/dev/null && echo \"1\" || echo \"0\"");
|
{
|
||||||
|
appendPQExpBuffer(&remote_command_str,
|
||||||
|
"witness register -d \\'%s\\' --force 2>/dev/null && echo \"1\" || echo \"0\"",
|
||||||
|
local_node_record.conninfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
appendPQExpBuffer(&remote_command_str,
|
||||||
|
"standby follow 2>/dev/null && echo \"1\" || echo \"0\"");
|
||||||
|
}
|
||||||
get_conninfo_value(cell->node_info->conninfo, "host", host);
|
get_conninfo_value(cell->node_info->conninfo, "host", host);
|
||||||
log_debug("executing:\n %s", remote_command_str.data);
|
log_debug("executing:\n %s", remote_command_str.data);
|
||||||
|
|
||||||
@@ -3901,8 +3907,16 @@ do_standby_switchover(void)
|
|||||||
|
|
||||||
if (success == false || command_output.data[0] == '0')
|
if (success == false || command_output.data[0] == '0')
|
||||||
{
|
{
|
||||||
log_warning(_("STANDBY FOLLOW failed on node \"%s\""),
|
if (sibling_node_record.type == WITNESS)
|
||||||
cell->node_info->node_name);
|
{
|
||||||
|
log_warning(_("WITNESS REGISTER failed on node \"%s\""),
|
||||||
|
cell->node_info->node_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log_warning(_("STANDBY FOLLOW failed on node \"%s\""),
|
||||||
|
cell->node_info->node_name);
|
||||||
|
}
|
||||||
failed_follow_count++;
|
failed_follow_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user