mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-25 08:06: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:
@@ -303,7 +303,7 @@ do_node_status(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_downstream_node_attached(conn, node_cell->node_info->node_name) != NODE_ATTACHED)
|
||||
if (is_downstream_node_attached(conn, node_cell->node_info->node_name, NULL) != NODE_ATTACHED)
|
||||
{
|
||||
missing_nodes_count++;
|
||||
item_list_append_format(&missing_nodes,
|
||||
@@ -1227,7 +1227,7 @@ do_node_check_downstream(PGconn *conn, OutputMode mode, t_node_info *node_info,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_downstream_node_attached(conn, cell->node_info->node_name) != NODE_ATTACHED)
|
||||
if (is_downstream_node_attached(conn, cell->node_info->node_name, NULL) != NODE_ATTACHED)
|
||||
{
|
||||
missing_nodes_count++;
|
||||
item_list_append_format(&missing_nodes,
|
||||
@@ -1410,7 +1410,7 @@ do_node_check_upstream(PGconn *conn, OutputMode mode, t_node_info *node_info, Ch
|
||||
upstream_conn = establish_db_connection(upstream_node_info.conninfo, true);
|
||||
|
||||
/* check our node 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)
|
||||
{
|
||||
appendPQExpBuffer(&details,
|
||||
_("node \"%s\" (ID: %i) is not attached to expected upstream node \"%s\" (ID: %i)"),
|
||||
@@ -2799,7 +2799,7 @@ do_node_rejoin(void)
|
||||
config_file_options.node_rejoin_timeout);
|
||||
}
|
||||
else {
|
||||
log_detail(_("no record for local node \"%s\" found in node \"%s\"'s \"pg_stat_replication\" table"),
|
||||
log_detail(_("no active record for local node \"%s\" found in node \"%s\"'s \"pg_stat_replication\" table"),
|
||||
config_file_options.node_name,
|
||||
primary_node_record.node_name);
|
||||
}
|
||||
@@ -2811,7 +2811,7 @@ do_node_rejoin(void)
|
||||
else
|
||||
{
|
||||
/* -W/--no-wait provided - check once */
|
||||
NodeAttached node_attached = is_downstream_node_attached(primary_conn, config_file_options.node_name);
|
||||
NodeAttached node_attached = is_downstream_node_attached(primary_conn, config_file_options.node_name, NULL);
|
||||
if (node_attached == NODE_ATTACHED)
|
||||
success = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user