Hi all, (Thomas in CC as per 6912acc0) I got surprised by the following behavior from pg_stat_get_wal_senders when connecting for example pg_receivewal to a primary: =# select application_name, flush_lsn, replay_lsn, flush_lag, replay_lag from pg_stat_replication; application_name | flush_lsn | replay_lsn | flush_lag | replay_lag ------------------+-----------+------------+-----------------+----------------- receivewal | null | null | 00:09:13.578185 | 00:09:13.578185 (1 row)
It makes little sense to me, as we are reporting a replay lag on a position which has never been reported yet, so it cannot actually be used as a comparison base for the lag. Am I missing something or should we return NULL for those fields if we have no write, flush or apply LSNs like in the attached? Thoughts? -- Michael
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index e7a59b0a92..61fc9889db 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -3346,17 +3346,17 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS) */ priority = XLogRecPtrIsInvalid(flush) ? 0 : priority; - if (writeLag < 0) + if (writeLag < 0 || XLogRecPtrIsInvalid(write)) nulls[6] = true; else values[6] = IntervalPGetDatum(offset_to_interval(writeLag)); - if (flushLag < 0) + if (flushLag < 0 || XLogRecPtrIsInvalid(flush)) nulls[7] = true; else values[7] = IntervalPGetDatum(offset_to_interval(flushLag)); - if (applyLag < 0) + if (applyLag < 0 || XLogRecPtrIsInvalid(apply)) nulls[8] = true; else values[8] = IntervalPGetDatum(offset_to_interval(applyLag));
signature.asc
Description: PGP signature