Re: Fix lag columns in pg_stat_replication not advancing when replay LSN stalls

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
Cc: Shinya Kato <shinya11(dot)kato(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Subject: Re: Fix lag columns in pg_stat_replication not advancing when replay LSN stalls
Date: 2025-10-22 14:45:39
Message-ID: CAHGQGwHoyCd_Sv7JyqXYd5_Mppccvr9ttH9yoiydDJZ8KVtmnw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Oct 22, 2025 at 4:49 PM Xuneng Zhou <xunengzhou(at)gmail(dot)com> wrote:
> How about something like:
>
> /*
> * Overflow entries for read heads that collide with the write head.
> *
> * When the cyclic buffer fills (write head is about to collide with a read
> * head), we save that read head's current sample here and mark it as using
> * overflow (read_heads[i] = -1). This allows the write head to continue
> * advancing while the overflowed mode continues lag computation using the
> * saved sample.
> *
> * Once the standby's reported LSN advances past the overflow entry's LSN,
> * we transition back to normal buffer-based tracking.
> */

LGTM. Thanks!

I've created a patch adding your suggested comments (attached).
Since this is a follow-up to commit 883a95646a8, which was recently applied
and backpatched to all supported branches, I think we should backpatch
this one as well. Thought?

Regards,

--
Fujii Masao

Attachment Content-Type Size
v1-0001-Add-comments-explaining-overflow-entries-in-the-r.patch application/octet-stream 2.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Matheus Alcantara 2025-10-22 15:23:42 Re: LISTEN/NOTIFY bug: VACUUM sets frozenxid past a xid in async queue
Previous Message Bertrand Drouvot 2025-10-22 14:41:42 Re: Skip unregistered custom kinds on stats load