mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 00:46:29 +00:00
23
repmgrd.c
23
repmgrd.c
@@ -664,7 +664,7 @@ witness_monitor(void)
|
|||||||
local_options.master_response_timeout) != 1)
|
local_options.master_response_timeout) != 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Get local xlog info */
|
/* Get timestamp for monitoring update */
|
||||||
sqlquery_snprintf(sqlquery, "SELECT CURRENT_TIMESTAMP");
|
sqlquery_snprintf(sqlquery, "SELECT CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
res = PQexec(my_local_conn, sqlquery);
|
res = PQexec(my_local_conn, sqlquery);
|
||||||
@@ -1081,12 +1081,19 @@ standby_monitor(void)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Get local xlog info */
|
/* Get local xlog info */
|
||||||
|
|
||||||
sqlquery_snprintf(sqlquery,
|
sqlquery_snprintf(sqlquery,
|
||||||
"SELECT CURRENT_TIMESTAMP, "
|
" SELECT ts, "
|
||||||
"pg_catalog.pg_last_xlog_receive_location(), "
|
" receive_location, "
|
||||||
"pg_catalog.pg_last_xlog_replay_location(), "
|
" replay_location, "
|
||||||
"pg_catalog.pg_last_xact_replay_timestamp(), "
|
" replay_timestamp, "
|
||||||
"pg_catalog.pg_last_xlog_receive_location() >= pg_catalog.pg_last_xlog_replay_location()");
|
" receive_location >= replay_location "
|
||||||
|
" FROM (SELECT CURRENT_TIMESTAMP AS ts, "
|
||||||
|
" pg_catalog.pg_last_xlog_receive_location() AS receive_location, "
|
||||||
|
" pg_catalog.pg_last_xlog_replay_location() AS replay_location, "
|
||||||
|
" pg_catalog.pg_last_xact_replay_timestamp() AS replay_timestamp "
|
||||||
|
" ) q ");
|
||||||
|
|
||||||
|
|
||||||
res = PQexec(my_local_conn, sqlquery);
|
res = PQexec(my_local_conn, sqlquery);
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
@@ -1171,10 +1178,12 @@ standby_monitor(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
apply_lag = (long long unsigned int)lsn_last_xlog_receive_location - lsn_last_xlog_replay_location;
|
|
||||||
lsn_last_xlog_receive_location = lsn_to_xlogrecptr(last_xlog_receive_location, NULL);
|
lsn_last_xlog_receive_location = lsn_to_xlogrecptr(last_xlog_receive_location, NULL);
|
||||||
|
|
||||||
|
apply_lag = (long long unsigned int)lsn_last_xlog_receive_location - lsn_last_xlog_replay_location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Calculate replication lag */
|
/* Calculate replication lag */
|
||||||
if (lsn_master_current_xlog_location >= lsn_last_xlog_receive_location)
|
if (lsn_master_current_xlog_location >= lsn_last_xlog_receive_location)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user