mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +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->receiving_streamed_wal = true;
|
||||
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, "
|
||||
" last_wal_receive_lsn >= last_wal_replay_lsn AS receiving_streamed_wal, "
|
||||
" wal_replay_paused, "
|
||||
" primary_last_seen "
|
||||
" upstream_last_seen "
|
||||
" FROM ( "
|
||||
" SELECT CURRENT_TIMESTAMP AS ts, "
|
||||
" 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,
|
||||
" CASE WHEN pg_catalog.pg_is_in_recovery() IS FALSE "
|
||||
" THEN -1 "
|
||||
" ELSE repmgr.get_primary_last_seen() "
|
||||
" END AS primary_last_seen "
|
||||
" ELSE repmgr.get_upstream_last_seen() "
|
||||
" END AS upstream_last_seen "
|
||||
" ) q ");
|
||||
|
||||
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->receiving_streamed_wal = atobool(PQgetvalue(res, 0, 5));
|
||||
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);
|
||||
@@ -5097,7 +5097,7 @@ is_downstream_node_attached(PGconn *conn, char *node_name)
|
||||
|
||||
|
||||
void
|
||||
set_primary_last_seen(PGconn *conn)
|
||||
set_upstream_last_seen(PGconn *conn)
|
||||
{
|
||||
PQExpBufferData query;
|
||||
PGresult *res = NULL;
|
||||
@@ -5105,13 +5105,13 @@ set_primary_last_seen(PGconn *conn)
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
"SELECT repmgr.set_primary_last_seen()");
|
||||
"SELECT repmgr.set_upstream_last_seen()");
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
|
||||
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);
|
||||
@@ -5120,35 +5120,35 @@ set_primary_last_seen(PGconn *conn)
|
||||
|
||||
|
||||
int
|
||||
get_primary_last_seen(PGconn *conn)
|
||||
get_upstream_last_seen(PGconn *conn)
|
||||
{
|
||||
PQExpBufferData query;
|
||||
PGresult *res = NULL;
|
||||
int primary_last_seen = -1;
|
||||
int upstream_last_seen = -1;
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
"SELECT CASE WHEN pg_catalog.pg_is_in_recovery() IS FALSE "
|
||||
" THEN -1 "
|
||||
" ELSE repmgr.get_primary_last_seen() "
|
||||
" END AS primary_last_seen ");
|
||||
" ELSE repmgr.get_upstream_last_seen() "
|
||||
" END AS upstream_last_seen ");
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
|
||||
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
|
||||
{
|
||||
primary_last_seen = atoi(PQgetvalue(res, 0, 0));
|
||||
upstream_last_seen = atoi(PQgetvalue(res, 0, 0));
|
||||
}
|
||||
|
||||
termPQExpBuffer(&query);
|
||||
PQclear(res);
|
||||
|
||||
return primary_last_seen;
|
||||
return upstream_last_seen;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -308,7 +308,7 @@ typedef struct
|
||||
int replication_lag_time;
|
||||
bool receiving_streamed_wal;
|
||||
bool wal_replay_paused;
|
||||
int primary_last_seen;
|
||||
int upstream_last_seen;
|
||||
} ReplInfo;
|
||||
|
||||
typedef struct
|
||||
@@ -555,8 +555,8 @@ bool get_replication_info(PGconn *conn, ReplInfo *replication_info);
|
||||
int get_replication_lag_seconds(PGconn *conn);
|
||||
void get_node_replication_stats(PGconn *conn, t_node_info *node_info);
|
||||
bool is_downstream_node_attached(PGconn *conn, char *node_name);
|
||||
void set_primary_last_seen(PGconn *conn);
|
||||
int get_primary_last_seen(PGconn *conn);
|
||||
void set_upstream_last_seen(PGconn *conn);
|
||||
int get_upstream_last_seen(PGconn *conn);
|
||||
bool is_wal_replay_paused(PGconn *conn, bool check_pending_wal);
|
||||
|
||||
/* BDR functions */
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "CREATE EXTENSION repmgr" to load this file. \quit
|
||||
|
||||
CREATE FUNCTION set_primary_last_seen()
|
||||
CREATE FUNCTION set_upstream_last_seen()
|
||||
RETURNS VOID
|
||||
AS 'MODULE_PATHNAME', 'set_primary_last_seen'
|
||||
AS 'MODULE_PATHNAME', 'set_upstream_last_seen'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION get_primary_last_seen()
|
||||
CREATE FUNCTION get_upstream_last_seen()
|
||||
RETURNS INT
|
||||
AS 'MODULE_PATHNAME', 'get_primary_last_seen'
|
||||
AS 'MODULE_PATHNAME', 'get_upstream_last_seen'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
@@ -118,14 +118,14 @@ CREATE FUNCTION standby_get_last_updated()
|
||||
AS 'MODULE_PATHNAME', 'standby_get_last_updated'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION set_primary_last_seen()
|
||||
CREATE FUNCTION set_upstream_last_seen()
|
||||
RETURNS VOID
|
||||
AS 'MODULE_PATHNAME', 'set_primary_last_seen'
|
||||
AS 'MODULE_PATHNAME', 'set_upstream_last_seen'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION get_primary_last_seen()
|
||||
CREATE FUNCTION get_upstream_last_seen()
|
||||
RETURNS INT
|
||||
AS 'MODULE_PATHNAME', 'get_primary_last_seen'
|
||||
AS 'MODULE_PATHNAME', 'get_upstream_last_seen'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
/* 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)
|
||||
{
|
||||
|
||||
20
repmgr.c
20
repmgr.c
@@ -77,7 +77,7 @@ typedef struct repmgrdSharedState
|
||||
char repmgrd_pidfile[MAXPGPATH];
|
||||
bool repmgrd_paused;
|
||||
/* streaming failover */
|
||||
TimestampTz primary_last_seen;
|
||||
TimestampTz upstream_last_seen;
|
||||
NodeVotingStatus voting_status;
|
||||
int current_electoral_term;
|
||||
int candidate_node_id;
|
||||
@@ -108,11 +108,11 @@ PG_FUNCTION_INFO_V1(standby_set_last_updated);
|
||||
Datum standby_get_last_updated(PG_FUNCTION_ARGS);
|
||||
PG_FUNCTION_INFO_V1(standby_get_last_updated);
|
||||
|
||||
Datum set_primary_last_seen(PG_FUNCTION_ARGS);
|
||||
PG_FUNCTION_INFO_V1(set_primary_last_seen);
|
||||
Datum set_upstream_last_seen(PG_FUNCTION_ARGS);
|
||||
PG_FUNCTION_INFO_V1(set_upstream_last_seen);
|
||||
|
||||
Datum get_primary_last_seen(PG_FUNCTION_ARGS);
|
||||
PG_FUNCTION_INFO_V1(get_primary_last_seen);
|
||||
Datum get_upstream_last_seen(PG_FUNCTION_ARGS);
|
||||
PG_FUNCTION_INFO_V1(get_upstream_last_seen);
|
||||
|
||||
Datum notify_follow_primary(PG_FUNCTION_ARGS);
|
||||
PG_FUNCTION_INFO_V1(notify_follow_primary);
|
||||
@@ -226,7 +226,7 @@ repmgr_shmem_startup(void)
|
||||
shared_state->repmgrd_paused = false;
|
||||
shared_state->current_electoral_term = 0;
|
||||
/* 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->candidate_node_id = UNKNOWN_NODE_ID;
|
||||
shared_state->follow_new_primary = false;
|
||||
@@ -363,14 +363,14 @@ standby_get_last_updated(PG_FUNCTION_ARGS)
|
||||
|
||||
|
||||
Datum
|
||||
set_primary_last_seen(PG_FUNCTION_ARGS)
|
||||
set_upstream_last_seen(PG_FUNCTION_ARGS)
|
||||
{
|
||||
if (!shared_state)
|
||||
PG_RETURN_VOID();
|
||||
|
||||
LWLockAcquire(shared_state->lock, LW_EXCLUSIVE);
|
||||
|
||||
shared_state->primary_last_seen = GetCurrentTimestamp();
|
||||
shared_state->upstream_last_seen = GetCurrentTimestamp();
|
||||
|
||||
LWLockRelease(shared_state->lock);
|
||||
|
||||
@@ -379,7 +379,7 @@ set_primary_last_seen(PG_FUNCTION_ARGS)
|
||||
|
||||
|
||||
Datum
|
||||
get_primary_last_seen(PG_FUNCTION_ARGS)
|
||||
get_upstream_last_seen(PG_FUNCTION_ARGS)
|
||||
{
|
||||
long secs;
|
||||
int microsecs;
|
||||
@@ -394,7 +394,7 @@ get_primary_last_seen(PG_FUNCTION_ARGS)
|
||||
|
||||
LWLockAcquire(shared_state->lock, LW_SHARED);
|
||||
|
||||
last_seen = shared_state->primary_last_seen;
|
||||
last_seen = shared_state->upstream_last_seen;
|
||||
|
||||
LWLockRelease(shared_state->lock);
|
||||
|
||||
|
||||
@@ -833,7 +833,7 @@ monitor_streaming_standby(void)
|
||||
log_verbose(LOG_DEBUG, "checking %s", upstream_node_info.conninfo);
|
||||
if (is_server_available(upstream_node_info.conninfo) == true)
|
||||
{
|
||||
set_primary_last_seen(local_conn);
|
||||
set_upstream_last_seen(local_conn);
|
||||
}
|
||||
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++;
|
||||
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,
|
||||
" - node \"%s\" (ID: %i): %i second(s) ago\n",
|
||||
cell->node_info->node_name,
|
||||
cell->node_info->node_id,
|
||||
sibling_replication_info.primary_last_seen);
|
||||
sibling_replication_info.upstream_last_seen);
|
||||
}
|
||||
else
|
||||
{
|
||||
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 */
|
||||
cell->node_info->last_wal_receive_lsn = sibling_replication_info.last_wal_receive_lsn;
|
||||
|
||||
Reference in New Issue
Block a user