Re: pg_stat_replication.*_lag sometimes shows NULL during active replication

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Shinya Kato <shinya11(dot)kato(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_stat_replication.*_lag sometimes shows NULL during active replication
Date: 2026-03-25 15:30:42
Message-ID: CAHGQGwHLK5ObQShRx15OwBK4whO7MQ0VXveBtxDsMiibGUGK_g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Mar 25, 2026 at 4:03 PM Shinya Kato <shinya11(dot)kato(at)gmail(dot)com> wrote:
> Thanks for the updated patch. LGTM.
>
> Regarding the backpatch, I'd personally appreciate it if the walsender.c changes were backpatched to stable branches. As you noted, it don't fully solve the reported issue, but they do help reduce the cases where lag columns in pg_stat_replication unexpectedly become NULL.
>
> Even a partial mitigation in the back branches would be valuable for users running stable releases.

+1

I've split the changes into two patches.

Patch 0001 fixes premature NULL lag reporting in walsender. I will commit it
and backpatch it to all supported branches.

Patch 0002 avoids sending duplicate WAL locations in standby status replies.
I will commit this to master only.

Regards,

--
Fujii Masao

Attachment Content-Type Size
v7-0002-Avoid-sending-duplicate-WAL-locations-in-standby-.patch application/octet-stream 10.3 KB
v7-0001-Fix-premature-NULL-lag-reporting-in-pg_stat_repli.patch application/octet-stream 4.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Melanie Plageman 2026-03-25 15:33:08 Re: Don't synchronously wait for already-in-progress IO in read stream
Previous Message Fujii Masao 2026-03-25 15:27:37 Re: pg_stat_replication.*_lag sometimes shows NULL during active replication