pg_stat_replication lag fields return non-NULL values even with NULL LSNs

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
Subject: pg_stat_replication lag fields return non-NULL values even with NULL LSNs
Date: 2019-07-17 01:51:44
Message-ID: 20190717015144.GB2130@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
lag-null-lsns-v1.patch text/x-diff 858 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2019-07-17 02:35:39 Re: buildfarm's typedefs list has gone completely nutso
Previous Message Melanie Plageman 2019-07-17 01:49:10 Re: Extracting only the columns needed for a query