Rename functions which return an LSN for clarity

This commit is contained in:
Ian Barwick
2019-02-06 09:30:45 +09:00
parent cce8b76171
commit cd3312496e
5 changed files with 21 additions and 11 deletions

View File

@@ -4551,9 +4551,16 @@ reset_voting_status(PGconn *conn)
/* replication status functions */ /* replication status functions */
/* ============================ */ /* ============================ */
/*
* Returns the current LSN on the primary.
*
* This just executes "pg_current_wal_lsn()".
*
* Function "get_node_current_lsn()" below will return the latest
* LSN regardless of recovery state.
*/
XLogRecPtr XLogRecPtr
get_current_wal_lsn(PGconn *conn) get_primary_current_lsn(PGconn *conn)
{ {
PGresult *res = NULL; PGresult *res = NULL;
XLogRecPtr ptr = InvalidXLogRecPtr; XLogRecPtr ptr = InvalidXLogRecPtr;
@@ -4577,6 +4584,7 @@ get_current_wal_lsn(PGconn *conn)
return ptr; return ptr;
} }
XLogRecPtr XLogRecPtr
get_last_wal_receive_location(PGconn *conn) get_last_wal_receive_location(PGconn *conn)
{ {
@@ -4602,9 +4610,11 @@ get_last_wal_receive_location(PGconn *conn)
return ptr; return ptr;
} }
/*
* Returns the latest LSN for the node regardless of recovery state.
*/
XLogRecPtr XLogRecPtr
get_current_lsn(PGconn *conn) get_node_current_lsn(PGconn *conn)
{ {
PQExpBufferData query; PQExpBufferData query;
PGresult *res = NULL; PGresult *res = NULL;
@@ -4678,7 +4688,7 @@ get_current_lsn(PGconn *conn)
if (PQresultStatus(res) != PGRES_TUPLES_OK) if (PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
log_db_error(conn, query.data, _("unable to execute get_current_lsn()")); log_db_error(conn, query.data, _("unable to execute get_node_current_lsn()"));
} }
else if (!PQgetisnull(res, 0, 0)) else if (!PQgetisnull(res, 0, 0))
{ {

View File

@@ -538,9 +538,9 @@ bool get_new_primary(PGconn *conn, int *primary_node_id);
void reset_voting_status(PGconn *conn); void reset_voting_status(PGconn *conn);
/* replication status functions */ /* replication status functions */
XLogRecPtr get_current_wal_lsn(PGconn *conn); XLogRecPtr get_primary_current_lsn(PGconn *conn);
XLogRecPtr get_node_current_lsn(PGconn *conn);
XLogRecPtr get_last_wal_receive_location(PGconn *conn); XLogRecPtr get_last_wal_receive_location(PGconn *conn);
XLogRecPtr get_current_lsn(PGconn *conn);
void init_replication_info(ReplInfo *replication_info); void init_replication_info(ReplInfo *replication_info);
bool get_replication_info(PGconn *conn, ReplInfo *replication_info); bool get_replication_info(PGconn *conn, ReplInfo *replication_info);
int get_replication_lag_seconds(PGconn *conn); int get_replication_lag_seconds(PGconn *conn);

View File

@@ -2532,7 +2532,7 @@ do_standby_follow(void)
t_system_identification local_identification = T_SYSTEM_IDENTIFICATION_INITIALIZER; t_system_identification local_identification = T_SYSTEM_IDENTIFICATION_INITIALIZER;
bool can_follow; bool can_follow;
XLogRecPtr local_xlogpos = get_current_lsn(local_conn); XLogRecPtr local_xlogpos = get_node_current_lsn(local_conn);
/* Check local replication connection - we want to execute IDENTIFY_SYSTEM /* Check local replication connection - we want to execute IDENTIFY_SYSTEM
* to get the current timeline ID, which might not yet be written to * to get the current timeline ID, which might not yet be written to
@@ -3234,7 +3234,7 @@ do_standby_switchover(void)
* to unexpected behaviour when the standby is promoted. * to unexpected behaviour when the standby is promoted.
* *
* For switchover we'll mandate that WAL replay *must not* be paused. * For switchover we'll mandate that WAL replay *must not* be paused.
* For a promote operation we can proceed if WAL replay is paused * For a promote operation we can proceed if WAL replay is paused and
* there is no more available WAL to be replayed, as we can be sure the * there is no more available WAL to be replayed, as we can be sure the
* primary is down already, but in a switchover context there's * primary is down already, but in a switchover context there's
* potentially a window for more WAL to be received before we shut down * potentially a window for more WAL to be received before we shut down

View File

@@ -3321,7 +3321,7 @@ check_node_can_attach(TimeLineID local_tli, XLogRecPtr local_xlogpos, PGconn *fo
if (follow_target_identification.timeline == local_tli) if (follow_target_identification.timeline == local_tli)
{ {
XLogRecPtr follow_target_xlogpos = get_current_lsn(follow_target_conn); XLogRecPtr follow_target_xlogpos = get_node_current_lsn(follow_target_conn);
if (local_xlogpos == InvalidXLogRecPtr || follow_target_xlogpos == InvalidXLogRecPtr) if (local_xlogpos == InvalidXLogRecPtr || follow_target_xlogpos == InvalidXLogRecPtr)
{ {

View File

@@ -2242,7 +2242,7 @@ update_monitoring_history(void)
local_node_info.node_id); local_node_info.node_id);
} }
primary_last_wal_location = get_current_wal_lsn(primary_conn); primary_last_wal_location = get_primary_current_lsn(primary_conn);
if (primary_last_wal_location == InvalidXLogRecPtr) if (primary_last_wal_location == InvalidXLogRecPtr)
{ {