mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-24 07:36:30 +00:00
repmgrd: remove unneeded functions
This commit is contained in:
96
dbutils.c
96
dbutils.c
@@ -3647,102 +3647,6 @@ get_voting_status(PGconn *conn)
|
||||
}
|
||||
|
||||
|
||||
VoteRequestResult
|
||||
request_vote(PGconn *conn, t_node_info *this_node, t_node_info *other_node, int electoral_term)
|
||||
{
|
||||
PQExpBufferData query;
|
||||
PGresult *res = NULL;
|
||||
int lsn_diff = 0;
|
||||
|
||||
other_node->last_wal_receive_lsn = InvalidXLogRecPtr;
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBuffer(&query,
|
||||
"SELECT repmgr.request_vote(%i, %i)",
|
||||
this_node->node_id,
|
||||
electoral_term);
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
termPQExpBuffer(&query);
|
||||
|
||||
/* check for NULL */
|
||||
if (PQgetisnull(res, 0, 0))
|
||||
{
|
||||
PQclear(res);
|
||||
|
||||
log_debug("NULL returned by repmgr.request_vote()");
|
||||
|
||||
/*
|
||||
* get the node's last receive location anyway TODO: have
|
||||
* repmgr.request_vote() return two values
|
||||
*/
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
if (server_version_num >= 100000)
|
||||
{
|
||||
appendPQExpBuffer(&query,
|
||||
"SELECT pg_catalog.pg_last_wal_receive_lsn()");
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBuffer(&query,
|
||||
"SELECT pg_catalog.pg_last_xlog_receive_location()");
|
||||
}
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
termPQExpBuffer(&query);
|
||||
|
||||
if (PQresultStatus(res) == PGRES_TUPLES_OK)
|
||||
{
|
||||
other_node->last_wal_receive_lsn = parse_lsn(PQgetvalue(res, 0, 0));
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
return VR_VOTE_REFUSED;
|
||||
}
|
||||
|
||||
other_node->last_wal_receive_lsn = parse_lsn(PQgetvalue(res, 0, 0));
|
||||
|
||||
PQclear(res);
|
||||
|
||||
lsn_diff = this_node->last_wal_receive_lsn - other_node->last_wal_receive_lsn;
|
||||
|
||||
log_debug("lsn_diff %i", lsn_diff);
|
||||
|
||||
/* we're ahead */
|
||||
if (lsn_diff > 0)
|
||||
{
|
||||
log_debug("local node is ahead");
|
||||
return VR_POSITIVE_VOTE;
|
||||
}
|
||||
|
||||
|
||||
/* other node is ahead */
|
||||
if (lsn_diff < 0)
|
||||
{
|
||||
log_debug("other node is ahead");
|
||||
return VR_NEGATIVE_VOTE;
|
||||
}
|
||||
|
||||
/* tiebreak */
|
||||
|
||||
/* other node is higher priority */
|
||||
if (this_node->priority < other_node->priority)
|
||||
{
|
||||
log_debug("other node has higher priority");
|
||||
return VR_NEGATIVE_VOTE;
|
||||
}
|
||||
|
||||
/* still tiebreak - we're the candidate, so we win */
|
||||
log_debug("win by default");
|
||||
return VR_POSITIVE_VOTE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
set_voting_status_initiated(PGconn *conn, int electoral_term)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user