mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 08:56:29 +00:00
Store WAL replay pause status in ReplInfo struct
This commit is contained in:
21
dbutils.c
21
dbutils.c
@@ -4711,6 +4711,7 @@ init_replication_info(ReplInfo *replication_info)
|
|||||||
memset(replication_info->last_xact_replay_timestamp, 0, sizeof(replication_info->last_xact_replay_timestamp));
|
memset(replication_info->last_xact_replay_timestamp, 0, sizeof(replication_info->last_xact_replay_timestamp));
|
||||||
replication_info->replication_lag_time = 0;
|
replication_info->replication_lag_time = 0;
|
||||||
replication_info->receiving_streamed_wal = true;
|
replication_info->receiving_streamed_wal = true;
|
||||||
|
replication_info->wal_replay_paused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4736,7 +4737,8 @@ get_replication_info(PGconn *conn, ReplInfo *replication_info)
|
|||||||
" EXTRACT(epoch FROM (pg_catalog.clock_timestamp() - last_xact_replay_timestamp))::INT "
|
" EXTRACT(epoch FROM (pg_catalog.clock_timestamp() - last_xact_replay_timestamp))::INT "
|
||||||
" END "
|
" END "
|
||||||
" END AS replication_lag_time, "
|
" END AS replication_lag_time, "
|
||||||
" last_wal_receive_lsn >= last_wal_replay_lsn AS receiving_streamed_wal "
|
" last_wal_receive_lsn >= last_wal_replay_lsn AS receiving_streamed_wal, "
|
||||||
|
" wal_replay_paused "
|
||||||
" FROM ( "
|
" FROM ( "
|
||||||
" SELECT CURRENT_TIMESTAMP AS ts, "
|
" SELECT CURRENT_TIMESTAMP AS ts, "
|
||||||
" pg_catalog.pg_last_xact_replay_timestamp() AS last_xact_replay_timestamp, ");
|
" pg_catalog.pg_last_xact_replay_timestamp() AS last_xact_replay_timestamp, ");
|
||||||
@@ -4746,8 +4748,11 @@ get_replication_info(PGconn *conn, ReplInfo *replication_info)
|
|||||||
{
|
{
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" COALESCE(pg_catalog.pg_last_wal_receive_lsn(), '0/0'::PG_LSN) AS last_wal_receive_lsn, "
|
" COALESCE(pg_catalog.pg_last_wal_receive_lsn(), '0/0'::PG_LSN) AS last_wal_receive_lsn, "
|
||||||
" COALESCE(pg_catalog.pg_last_wal_replay_lsn(), '0/0'::PG_LSN) AS last_wal_replay_lsn ");
|
" COALESCE(pg_catalog.pg_last_wal_replay_lsn(), '0/0'::PG_LSN) AS last_wal_replay_lsn, "
|
||||||
|
" 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 ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -4755,16 +4760,21 @@ get_replication_info(PGconn *conn, ReplInfo *replication_info)
|
|||||||
{
|
{
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" COALESCE(pg_catalog.pg_last_xlog_receive_location(), '0/0'::PG_LSN) AS last_wal_receive_lsn, "
|
" COALESCE(pg_catalog.pg_last_xlog_receive_location(), '0/0'::PG_LSN) AS last_wal_receive_lsn, "
|
||||||
" COALESCE(pg_catalog.pg_last_xlog_replay_location(), '0/0'::PG_LSN) AS last_wal_replay_lsn ");
|
" COALESCE(pg_catalog.pg_last_xlog_replay_location(), '0/0'::PG_LSN) AS last_wal_replay_lsn, ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* 9.3 does not have "pg_lsn" datatype */
|
/* 9.3 does not have "pg_lsn" datatype */
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" COALESCE(pg_catalog.pg_last_xlog_receive_location(), '0/0') AS last_wal_receive_lsn, "
|
" COALESCE(pg_catalog.pg_last_xlog_receive_location(), '0/0') AS last_wal_receive_lsn, "
|
||||||
" COALESCE(pg_catalog.pg_last_xlog_replay_location(), '0/0') AS last_wal_replay_lsn ");
|
" COALESCE(pg_catalog.pg_last_xlog_replay_location(), '0/0') AS last_wal_replay_lsn, ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
appendPQExpBufferStr(&query,
|
||||||
|
" 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 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBufferStr(&query,
|
||||||
@@ -4788,6 +4798,7 @@ get_replication_info(PGconn *conn, ReplInfo *replication_info)
|
|||||||
strncpy(replication_info->last_xact_replay_timestamp, PQgetvalue(res, 0, 3), MAXLEN);
|
strncpy(replication_info->last_xact_replay_timestamp, PQgetvalue(res, 0, 3), MAXLEN);
|
||||||
replication_info->replication_lag_time = atoi(PQgetvalue(res, 0, 4));
|
replication_info->replication_lag_time = atoi(PQgetvalue(res, 0, 4));
|
||||||
replication_info->receiving_streamed_wal = atobool(PQgetvalue(res, 0, 5));
|
replication_info->receiving_streamed_wal = atobool(PQgetvalue(res, 0, 5));
|
||||||
|
replication_info->wal_replay_paused = atobool(PQgetvalue(res, 0, 6));
|
||||||
}
|
}
|
||||||
|
|
||||||
termPQExpBuffer(&query);
|
termPQExpBuffer(&query);
|
||||||
|
|||||||
@@ -306,6 +306,7 @@ typedef struct
|
|||||||
char last_xact_replay_timestamp[MAXLEN];
|
char last_xact_replay_timestamp[MAXLEN];
|
||||||
int replication_lag_time;
|
int replication_lag_time;
|
||||||
bool receiving_streamed_wal;
|
bool receiving_streamed_wal;
|
||||||
|
bool wal_replay_paused;
|
||||||
} ReplInfo;
|
} ReplInfo;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|||||||
Reference in New Issue
Block a user