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: Shinya Kato <shinya11(dot)kato(at)gmail(dot)com>
Cc: 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-20 01:17:21
Message-ID: CAHGQGwE26-Ei8iMr-O2ABGs4mW=XC9f_90CVf5oLv-mNJ3BGOQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Oct 19, 2025 at 2:04 AM Shinya Kato <shinya11(dot)kato(at)gmail(dot)com> wrote:
> Thank you for the patch. I have one comment.
>
> + if (lag_tracker->overflowed[head].lsn > lsn)
> + return now - lag_tracker->overflowed[head].time;
>
> Could this return a negative value if the clock somehow went
> backwards? The original code returns -1 in this case, so I'm curious
> about this.

Thanks for the review!

Yes, you're right. So I've updated the patch so that -1 is returned
when the current time is earlier than the time in the overflow entry,
treating it as "no new sample found".

Regards,

--
Fujii Masao

Attachment Content-Type Size
v3-0001-Fix-stalled-lag-columns-in-pg_stat_replication-wh.patch application/octet-stream 4.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2025-10-20 01:20:41 Re: Fix lag columns in pg_stat_replication not advancing when replay LSN stalls
Previous Message Fujii Masao 2025-10-20 01:12:07 Re: Fix lag columns in pg_stat_replication not advancing when replay LSN stalls