mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 16:46:28 +00:00
Rename "..._primary_last_seen" functions to "..._upstream_last_seen"
As that better reflects what they do.
This commit is contained in:
30
dbutils.c
30
dbutils.c
@@ -4818,7 +4818,7 @@ init_replication_info(ReplInfo *replication_info)
|
|||||||
replication_info->replication_lag_time = 0;
|
replication_info->replication_lag_time = 0;
|
||||||
replication_info->receiving_streamed_wal = true;
|
replication_info->receiving_streamed_wal = true;
|
||||||
replication_info->wal_replay_paused = false;
|
replication_info->wal_replay_paused = false;
|
||||||
replication_info->primary_last_seen = -1;
|
replication_info->upstream_last_seen = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4846,7 +4846,7 @@ get_replication_info(PGconn *conn, ReplInfo *replication_info)
|
|||||||
" END AS replication_lag_time, "
|
" END AS replication_lag_time, "
|
||||||
" last_wal_receive_lsn >= last_wal_replay_lsn AS receiving_streamed_wal, "
|
" last_wal_receive_lsn >= last_wal_replay_lsn AS receiving_streamed_wal, "
|
||||||
" wal_replay_paused, "
|
" wal_replay_paused, "
|
||||||
" primary_last_seen "
|
" upstream_last_seen "
|
||||||
" FROM ( "
|
" FROM ( "
|
||||||
" SELECT CURRENT_TIMESTAMP AS ts, "
|
" SELECT CURRENT_TIMESTAMP AS ts, "
|
||||||
" pg_catalog.pg_last_xact_replay_timestamp() AS last_xact_replay_timestamp, ");
|
" pg_catalog.pg_last_xact_replay_timestamp() AS last_xact_replay_timestamp, ");
|
||||||
@@ -4888,8 +4888,8 @@ get_replication_info(PGconn *conn, ReplInfo *replication_info)
|
|||||||
appendPQExpBufferStr(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" CASE WHEN pg_catalog.pg_is_in_recovery() IS FALSE "
|
" CASE WHEN pg_catalog.pg_is_in_recovery() IS FALSE "
|
||||||
" THEN -1 "
|
" THEN -1 "
|
||||||
" ELSE repmgr.get_primary_last_seen() "
|
" ELSE repmgr.get_upstream_last_seen() "
|
||||||
" END AS primary_last_seen "
|
" END AS upstream_last_seen "
|
||||||
" ) q ");
|
" ) q ");
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "get_replication_info():\n%s", query.data);
|
log_verbose(LOG_DEBUG, "get_replication_info():\n%s", query.data);
|
||||||
@@ -4911,7 +4911,7 @@ get_replication_info(PGconn *conn, ReplInfo *replication_info)
|
|||||||
replication_info->replication_lag_time = atoi(PQgetvalue(res, 0, 4));
|
replication_info->replication_lag_time = atoi(PQgetvalue(res, 0, 4));
|
||||||
replication_info->receiving_streamed_wal = atobool(PQgetvalue(res, 0, 5));
|
replication_info->receiving_streamed_wal = atobool(PQgetvalue(res, 0, 5));
|
||||||
replication_info->wal_replay_paused = atobool(PQgetvalue(res, 0, 6));
|
replication_info->wal_replay_paused = atobool(PQgetvalue(res, 0, 6));
|
||||||
replication_info->primary_last_seen = atoi(PQgetvalue(res, 0, 7));
|
replication_info->upstream_last_seen = atoi(PQgetvalue(res, 0, 7));
|
||||||
}
|
}
|
||||||
|
|
||||||
termPQExpBuffer(&query);
|
termPQExpBuffer(&query);
|
||||||
@@ -5097,7 +5097,7 @@ is_downstream_node_attached(PGconn *conn, char *node_name)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
set_primary_last_seen(PGconn *conn)
|
set_upstream_last_seen(PGconn *conn)
|
||||||
{
|
{
|
||||||
PQExpBufferData query;
|
PQExpBufferData query;
|
||||||
PGresult *res = NULL;
|
PGresult *res = NULL;
|
||||||
@@ -5105,13 +5105,13 @@ set_primary_last_seen(PGconn *conn)
|
|||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBufferStr(&query,
|
||||||
"SELECT repmgr.set_primary_last_seen()");
|
"SELECT repmgr.set_upstream_last_seen()");
|
||||||
|
|
||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
|
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
{
|
{
|
||||||
log_db_error(conn, query.data, _("unable to execute repmgr.set_primary_last_seen()"));
|
log_db_error(conn, query.data, _("unable to execute repmgr.set_upstream_last_seen()"));
|
||||||
}
|
}
|
||||||
|
|
||||||
termPQExpBuffer(&query);
|
termPQExpBuffer(&query);
|
||||||
@@ -5120,35 +5120,35 @@ set_primary_last_seen(PGconn *conn)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
get_primary_last_seen(PGconn *conn)
|
get_upstream_last_seen(PGconn *conn)
|
||||||
{
|
{
|
||||||
PQExpBufferData query;
|
PQExpBufferData query;
|
||||||
PGresult *res = NULL;
|
PGresult *res = NULL;
|
||||||
int primary_last_seen = -1;
|
int upstream_last_seen = -1;
|
||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBufferStr(&query,
|
||||||
"SELECT CASE WHEN pg_catalog.pg_is_in_recovery() IS FALSE "
|
"SELECT CASE WHEN pg_catalog.pg_is_in_recovery() IS FALSE "
|
||||||
" THEN -1 "
|
" THEN -1 "
|
||||||
" ELSE repmgr.get_primary_last_seen() "
|
" ELSE repmgr.get_upstream_last_seen() "
|
||||||
" END AS primary_last_seen ");
|
" END AS upstream_last_seen ");
|
||||||
|
|
||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
|
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
{
|
{
|
||||||
log_db_error(conn, query.data, _("unable to execute repmgr.get_primary_last_seen()"));
|
log_db_error(conn, query.data, _("unable to execute repmgr.get_upstream_last_seen()"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
primary_last_seen = atoi(PQgetvalue(res, 0, 0));
|
upstream_last_seen = atoi(PQgetvalue(res, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
termPQExpBuffer(&query);
|
termPQExpBuffer(&query);
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
return primary_last_seen;
|
return upstream_last_seen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ typedef struct
|
|||||||
int replication_lag_time;
|
int replication_lag_time;
|
||||||
bool receiving_streamed_wal;
|
bool receiving_streamed_wal;
|
||||||
bool wal_replay_paused;
|
bool wal_replay_paused;
|
||||||
int primary_last_seen;
|
int upstream_last_seen;
|
||||||
} ReplInfo;
|
} ReplInfo;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -555,8 +555,8 @@ bool get_replication_info(PGconn *conn, ReplInfo *replication_info);
|
|||||||
int get_replication_lag_seconds(PGconn *conn);
|
int get_replication_lag_seconds(PGconn *conn);
|
||||||
void get_node_replication_stats(PGconn *conn, t_node_info *node_info);
|
void get_node_replication_stats(PGconn *conn, t_node_info *node_info);
|
||||||
bool is_downstream_node_attached(PGconn *conn, char *node_name);
|
bool is_downstream_node_attached(PGconn *conn, char *node_name);
|
||||||
void set_primary_last_seen(PGconn *conn);
|
void set_upstream_last_seen(PGconn *conn);
|
||||||
int get_primary_last_seen(PGconn *conn);
|
int get_upstream_last_seen(PGconn *conn);
|
||||||
bool is_wal_replay_paused(PGconn *conn, bool check_pending_wal);
|
bool is_wal_replay_paused(PGconn *conn, bool check_pending_wal);
|
||||||
|
|
||||||
/* BDR functions */
|
/* BDR functions */
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||||
\echo Use "CREATE EXTENSION repmgr" to load this file. \quit
|
\echo Use "CREATE EXTENSION repmgr" to load this file. \quit
|
||||||
|
|
||||||
CREATE FUNCTION set_primary_last_seen()
|
CREATE FUNCTION set_upstream_last_seen()
|
||||||
RETURNS VOID
|
RETURNS VOID
|
||||||
AS 'MODULE_PATHNAME', 'set_primary_last_seen'
|
AS 'MODULE_PATHNAME', 'set_upstream_last_seen'
|
||||||
LANGUAGE C STRICT;
|
LANGUAGE C STRICT;
|
||||||
|
|
||||||
CREATE FUNCTION get_primary_last_seen()
|
CREATE FUNCTION get_upstream_last_seen()
|
||||||
RETURNS INT
|
RETURNS INT
|
||||||
AS 'MODULE_PATHNAME', 'get_primary_last_seen'
|
AS 'MODULE_PATHNAME', 'get_upstream_last_seen'
|
||||||
LANGUAGE C STRICT;
|
LANGUAGE C STRICT;
|
||||||
|
|||||||
@@ -118,14 +118,14 @@ CREATE FUNCTION standby_get_last_updated()
|
|||||||
AS 'MODULE_PATHNAME', 'standby_get_last_updated'
|
AS 'MODULE_PATHNAME', 'standby_get_last_updated'
|
||||||
LANGUAGE C STRICT;
|
LANGUAGE C STRICT;
|
||||||
|
|
||||||
CREATE FUNCTION set_primary_last_seen()
|
CREATE FUNCTION set_upstream_last_seen()
|
||||||
RETURNS VOID
|
RETURNS VOID
|
||||||
AS 'MODULE_PATHNAME', 'set_primary_last_seen'
|
AS 'MODULE_PATHNAME', 'set_upstream_last_seen'
|
||||||
LANGUAGE C STRICT;
|
LANGUAGE C STRICT;
|
||||||
|
|
||||||
CREATE FUNCTION get_primary_last_seen()
|
CREATE FUNCTION get_upstream_last_seen()
|
||||||
RETURNS INT
|
RETURNS INT
|
||||||
AS 'MODULE_PATHNAME', 'get_primary_last_seen'
|
AS 'MODULE_PATHNAME', 'get_upstream_last_seen'
|
||||||
LANGUAGE C STRICT;
|
LANGUAGE C STRICT;
|
||||||
|
|
||||||
/* failover functions */
|
/* failover functions */
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ do_daemon_status(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repmgrd_info[i]->upstream_last_seen = get_primary_last_seen(cell->node_info->conn);
|
repmgrd_info[i]->upstream_last_seen = get_upstream_last_seen(cell->node_info->conn);
|
||||||
|
|
||||||
if (repmgrd_info[i]->upstream_last_seen < 0)
|
if (repmgrd_info[i]->upstream_last_seen < 0)
|
||||||
{
|
{
|
||||||
|
|||||||
20
repmgr.c
20
repmgr.c
@@ -77,7 +77,7 @@ typedef struct repmgrdSharedState
|
|||||||
char repmgrd_pidfile[MAXPGPATH];
|
char repmgrd_pidfile[MAXPGPATH];
|
||||||
bool repmgrd_paused;
|
bool repmgrd_paused;
|
||||||
/* streaming failover */
|
/* streaming failover */
|
||||||
TimestampTz primary_last_seen;
|
TimestampTz upstream_last_seen;
|
||||||
NodeVotingStatus voting_status;
|
NodeVotingStatus voting_status;
|
||||||
int current_electoral_term;
|
int current_electoral_term;
|
||||||
int candidate_node_id;
|
int candidate_node_id;
|
||||||
@@ -108,11 +108,11 @@ PG_FUNCTION_INFO_V1(standby_set_last_updated);
|
|||||||
Datum standby_get_last_updated(PG_FUNCTION_ARGS);
|
Datum standby_get_last_updated(PG_FUNCTION_ARGS);
|
||||||
PG_FUNCTION_INFO_V1(standby_get_last_updated);
|
PG_FUNCTION_INFO_V1(standby_get_last_updated);
|
||||||
|
|
||||||
Datum set_primary_last_seen(PG_FUNCTION_ARGS);
|
Datum set_upstream_last_seen(PG_FUNCTION_ARGS);
|
||||||
PG_FUNCTION_INFO_V1(set_primary_last_seen);
|
PG_FUNCTION_INFO_V1(set_upstream_last_seen);
|
||||||
|
|
||||||
Datum get_primary_last_seen(PG_FUNCTION_ARGS);
|
Datum get_upstream_last_seen(PG_FUNCTION_ARGS);
|
||||||
PG_FUNCTION_INFO_V1(get_primary_last_seen);
|
PG_FUNCTION_INFO_V1(get_upstream_last_seen);
|
||||||
|
|
||||||
Datum notify_follow_primary(PG_FUNCTION_ARGS);
|
Datum notify_follow_primary(PG_FUNCTION_ARGS);
|
||||||
PG_FUNCTION_INFO_V1(notify_follow_primary);
|
PG_FUNCTION_INFO_V1(notify_follow_primary);
|
||||||
@@ -226,7 +226,7 @@ repmgr_shmem_startup(void)
|
|||||||
shared_state->repmgrd_paused = false;
|
shared_state->repmgrd_paused = false;
|
||||||
shared_state->current_electoral_term = 0;
|
shared_state->current_electoral_term = 0;
|
||||||
/* arbitrary "magic" date to indicate this field hasn't been updated */
|
/* arbitrary "magic" date to indicate this field hasn't been updated */
|
||||||
shared_state->primary_last_seen = POSTGRES_EPOCH_JDATE;
|
shared_state->upstream_last_seen = POSTGRES_EPOCH_JDATE;
|
||||||
shared_state->voting_status = VS_NO_VOTE;
|
shared_state->voting_status = VS_NO_VOTE;
|
||||||
shared_state->candidate_node_id = UNKNOWN_NODE_ID;
|
shared_state->candidate_node_id = UNKNOWN_NODE_ID;
|
||||||
shared_state->follow_new_primary = false;
|
shared_state->follow_new_primary = false;
|
||||||
@@ -363,14 +363,14 @@ standby_get_last_updated(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
set_primary_last_seen(PG_FUNCTION_ARGS)
|
set_upstream_last_seen(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
if (!shared_state)
|
if (!shared_state)
|
||||||
PG_RETURN_VOID();
|
PG_RETURN_VOID();
|
||||||
|
|
||||||
LWLockAcquire(shared_state->lock, LW_EXCLUSIVE);
|
LWLockAcquire(shared_state->lock, LW_EXCLUSIVE);
|
||||||
|
|
||||||
shared_state->primary_last_seen = GetCurrentTimestamp();
|
shared_state->upstream_last_seen = GetCurrentTimestamp();
|
||||||
|
|
||||||
LWLockRelease(shared_state->lock);
|
LWLockRelease(shared_state->lock);
|
||||||
|
|
||||||
@@ -379,7 +379,7 @@ set_primary_last_seen(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
get_primary_last_seen(PG_FUNCTION_ARGS)
|
get_upstream_last_seen(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
long secs;
|
long secs;
|
||||||
int microsecs;
|
int microsecs;
|
||||||
@@ -394,7 +394,7 @@ get_primary_last_seen(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
LWLockAcquire(shared_state->lock, LW_SHARED);
|
LWLockAcquire(shared_state->lock, LW_SHARED);
|
||||||
|
|
||||||
last_seen = shared_state->primary_last_seen;
|
last_seen = shared_state->upstream_last_seen;
|
||||||
|
|
||||||
LWLockRelease(shared_state->lock);
|
LWLockRelease(shared_state->lock);
|
||||||
|
|
||||||
|
|||||||
@@ -833,7 +833,7 @@ monitor_streaming_standby(void)
|
|||||||
log_verbose(LOG_DEBUG, "checking %s", upstream_node_info.conninfo);
|
log_verbose(LOG_DEBUG, "checking %s", upstream_node_info.conninfo);
|
||||||
if (is_server_available(upstream_node_info.conninfo) == true)
|
if (is_server_available(upstream_node_info.conninfo) == true)
|
||||||
{
|
{
|
||||||
set_primary_last_seen(local_conn);
|
set_upstream_last_seen(local_conn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -3332,21 +3332,21 @@ do_election(void)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
if (sibling_replication_info.primary_last_seen < (config_file_options.monitor_interval_secs * 2))
|
if (sibling_replication_info.upstream_last_seen < (config_file_options.monitor_interval_secs * 2))
|
||||||
{
|
{
|
||||||
nodes_with_primary_still_visible++;
|
nodes_with_primary_still_visible++;
|
||||||
log_notice(_("node %i last saw primary node %i second(s) ago, considering primary still visible"),
|
log_notice(_("node %i last saw primary node %i second(s) ago, considering primary still visible"),
|
||||||
cell->node_info->node_id, sibling_replication_info.primary_last_seen);
|
cell->node_info->node_id, sibling_replication_info.upstream_last_seen);
|
||||||
appendPQExpBuffer(&nodes_with_primary_visible,
|
appendPQExpBuffer(&nodes_with_primary_visible,
|
||||||
" - node \"%s\" (ID: %i): %i second(s) ago\n",
|
" - node \"%s\" (ID: %i): %i second(s) ago\n",
|
||||||
cell->node_info->node_name,
|
cell->node_info->node_name,
|
||||||
cell->node_info->node_id,
|
cell->node_info->node_id,
|
||||||
sibling_replication_info.primary_last_seen);
|
sibling_replication_info.upstream_last_seen);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log_info(_("node %i last saw primary node %i second(s) ago"),
|
log_info(_("node %i last saw primary node %i second(s) ago"),
|
||||||
cell->node_info->node_id, sibling_replication_info.primary_last_seen);
|
cell->node_info->node_id, sibling_replication_info.upstream_last_seen);
|
||||||
}
|
}
|
||||||
/* get node's last receive LSN - if "higher" than current winner, current node is candidate */
|
/* get node's last receive LSN - if "higher" than current winner, current node is candidate */
|
||||||
cell->node_info->last_wal_receive_lsn = sibling_replication_info.last_wal_receive_lsn;
|
cell->node_info->last_wal_receive_lsn = sibling_replication_info.last_wal_receive_lsn;
|
||||||
|
|||||||
Reference in New Issue
Block a user