Re: Allow reading LSN written by walreciever, but not flushed yet - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: Allow reading LSN written by walreciever, but not flushed yet
Date
Msg-id 339b1d92-e33f-45eb-951c-9832bcb0be3d@oss.nttdata.com
Whole thread Raw
In response to Re: Allow reading LSN written by walreciever, but not flushed yet  (Alexander Kukushkin <cyberdemn@gmail.com>)
List pgsql-hackers

On 2025/05/14 15:54, Alexander Kukushkin wrote:
> Hi Fujii,
> 
> 
> On Tue, 13 May 2025 at 13:13, Fujii Masao <masao.fujii@oss.nttdata.com <mailto:masao.fujii@oss.nttdata.com>> wrote:
> 
>     In this case, doesn't the flush LSN typically catch up to the write LSN on node2
>     after a few seconds? Even if the walreceiver exits while there's still written
>     but unflushed WAL, it looks like WalRcvDie() ensures everything is flushed by
>     calling XLogWalRcvFlush(). So, isn't it safe to rely on the flush LSN when selecting
>     the most advanced node? No?
> 
> 
> I think it is a bit more complex than that. There are also cases when we want to ensure that there are "healthy"
standbynodes when switchover is requested.
 
> Meaning of "healthy" could be something like: "According to the write LSN it is not lagging more than 16MB" or
similar.

Could we use the flush LSN instead of the write LSN for this?

By the way, in a switchover scenario where the primary is
shut down cleanly, it tries to send all remaining WAL records
to the standby before exiting. The walreceiver on the standby
then writes and flushes all those records before it exits.
So in this case, using the flush LSN to check for a "healthy"
state should work. But were you considering a different scenario?

Regards,

-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION




pgsql-hackers by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: psql : \dn+ to show default schema privileges
Next
From: Dmitry Koval
Date:
Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands