Re: Fix lag columns in pg_stat_replication not advancing when replay LSN stalls
Xuneng Zhou <xunengzhou@gmail.com>
From: Xuneng Zhou <xunengzhou@gmail.com>
To: Fujii Masao <masao.fujii@gmail.com>
Cc: Shinya Kato <shinya11.kato@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Chao Li <li.evan.chao@gmail.com>
Date: 2025-10-22T15:25:51Z
Lists: pgsql-hackers
Hi, On Wed, Oct 22, 2025 at 10:45 PM Fujii Masao <masao.fujii@gmail.com> wrote: > > On Wed, Oct 22, 2025 at 4:49 PM Xuneng Zhou <xunengzhou@gmail.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? > LGTM. Thanks for the patch! Best, Xuneng
Commits
-
Add comments explaining overflow entries in the replication lag tracker.
- b4810b4bb885 13.23 landed
- 10799d025f2c 14.20 landed
- c16154bfa2a1 15.15 landed
- 4d707f2fd728 16.11 landed
- 8ceab82ca526 17.7 landed
- 5f88da5de3f2 18.1 landed
- abc2b71383b4 19 (unreleased) landed
-
Fix stalled lag columns in pg_stat_replication when replay LSN stops advancing.
- 7d7ebdb800fe 13.23 landed
- a7ab6ce6a0fc 14.20 landed
- 59b215f7217f 15.15 landed
- 2e55cf4efc8d 16.11 landed
- 62d5ee75bbc4 17.7 landed
- 9670032cc51f 18.1 landed
- 883a95646a8e 19 (unreleased) landed