mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
Refactor is_wal_replay_paused() query
Make sure it doesn't emit an error if executed on a node not in recovery. The caller should theoretically only execute it on nodes in recovery, but there are sure to be corner cases where the node has come out of recovery.
This commit is contained in:
25
dbutils.c
25
dbutils.c
@@ -5079,26 +5079,37 @@ is_wal_replay_paused(PGconn *conn, bool check_pending_wal)
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
"SELECT paused.wal_replay_paused ");
|
||||
|
||||
if (PQserverVersion(conn) >= 100000)
|
||||
{
|
||||
appendPQExpBufferStr(&query,
|
||||
"SELECT pg_catalog.pg_is_wal_replay_paused()");
|
||||
|
||||
if (check_pending_wal == true)
|
||||
{
|
||||
appendPQExpBufferStr(&query,
|
||||
" AND pg_catalog.pg_last_wal_replay_lsn() < pg_catalog.pg_last_wal_receive_lsn()");
|
||||
" AND pg_catalog.pg_last_wal_replay_lsn() < pg_catalog.pg_last_wal_receive_lsn() ");
|
||||
}
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" FROM (SELECT CASE WHEN pg_catalog.pg_is_in_recovery() IS FALSE "
|
||||
" THEN FALSE "
|
||||
" ELSE pg_catalog.pg_is_wal_replay_paused() "
|
||||
" END AS wal_replay_paused) paused ");
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferStr(&query,
|
||||
"SELECT pg_catalog.pg_is_xlog_replay_paused()");
|
||||
if (check_pending_wal == true)
|
||||
{
|
||||
appendPQExpBufferStr(&query,
|
||||
" AND pg_catalog.pg_last_xlog_replay_location() < pg_catalog.pg_last_xlog_receive_location()");
|
||||
" AND pg_catalog.pg_last_xlog_replay_location() < pg_catalog.pg_last_xlog_receive_location() ");
|
||||
}
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" FROM (SELECT CASE WHEN pg_catalog.pg_is_in_recovery() IS FALSE "
|
||||
" THEN FALSE "
|
||||
" ELSE pg_catalog.pg_is_xlog_replay_paused() "
|
||||
" END AS wal_replay_paused) paused ");
|
||||
|
||||
}
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
|
||||
Reference in New Issue
Block a user