mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 08:56:29 +00:00
Improve replication connection check
Previously the check verifying that a node has connected to its upstream merely assumed the presence of a record in pg_stat_replication indicates a successful replication connection. However the record may contain a state other than "streaming", typically "startup" (which will occur when a node has diverged from its upstream and will therefore never transition to "streaming"), which needs to be taken into account when considering the state of the replication connection to avoid false positives.
This commit is contained in:
@@ -1797,7 +1797,7 @@ do_standby_register(void)
|
||||
else
|
||||
{
|
||||
/* check our standby is connected */
|
||||
if (is_downstream_node_attached(upstream_conn, config_file_options.node_name) == NODE_ATTACHED)
|
||||
if (is_downstream_node_attached(upstream_conn, config_file_options.node_name, NULL) == NODE_ATTACHED)
|
||||
{
|
||||
log_verbose(LOG_INFO, _("local node is attached to specified upstream node %i"), runtime_options.upstream_node_id);
|
||||
}
|
||||
@@ -1856,7 +1856,7 @@ do_standby_register(void)
|
||||
primary_node_id);
|
||||
|
||||
/* check our standby is connected */
|
||||
if (is_downstream_node_attached(primary_conn, config_file_options.node_name) == NODE_ATTACHED)
|
||||
if (is_downstream_node_attached(primary_conn, config_file_options.node_name, NULL) == NODE_ATTACHED)
|
||||
{
|
||||
log_verbose(LOG_INFO, _("local node is attached to primary"));
|
||||
}
|
||||
@@ -3073,7 +3073,9 @@ do_standby_follow(void)
|
||||
|
||||
for (timer = 0; timer < config_file_options.standby_follow_timeout; timer++)
|
||||
{
|
||||
NodeAttached node_attached = is_downstream_node_attached(follow_target_conn, config_file_options.node_name);
|
||||
NodeAttached node_attached = is_downstream_node_attached(follow_target_conn,
|
||||
config_file_options.node_name,
|
||||
NULL);
|
||||
|
||||
if (node_attached == NODE_ATTACHED)
|
||||
{
|
||||
@@ -3711,7 +3713,7 @@ do_standby_switchover(void)
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
|
||||
if (is_downstream_node_attached(remote_conn, local_node_record.node_name) != NODE_ATTACHED)
|
||||
if (is_downstream_node_attached(remote_conn, local_node_record.node_name, NULL) != NODE_ATTACHED)
|
||||
{
|
||||
log_error(_("local node \"%s\" (ID: %i) is not attached to demotion candidate \"%s\" (ID: %i)"),
|
||||
local_node_record.node_name,
|
||||
@@ -5195,7 +5197,8 @@ do_standby_switchover(void)
|
||||
*/
|
||||
|
||||
node_attached = is_downstream_node_attached(local_conn,
|
||||
remote_node_record.node_name);
|
||||
remote_node_record.node_name,
|
||||
NULL);
|
||||
if (node_attached == NODE_ATTACHED)
|
||||
{
|
||||
switchover_success = true;
|
||||
|
||||
Reference in New Issue
Block a user