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

From Rahila Syed
Subject Re: Allow reading LSN written by walreciever, but not flushed yet
Date
Msg-id CAH2L28st0ajc1k6y8CH2aTPVXd+kdPSm_6b+9VFGVx-6XMuTFw@mail.gmail.com
Whole thread Raw
In response to Re: Allow reading LSN written by walreciever, but not flushed yet  (Fujii Masao <masao.fujii@oss.nttdata.com>)
Responses Re: Allow reading LSN written by walreciever, but not flushed yet
List pgsql-hackers
Hi,

I've been following this discussion and have a question I'd like to ask.  

XLogWalRcvFlush() only updates flushedUpto if LogstreamResult.Flush has advanced,
while XLogWalRcvWrite() updates writtenUpto unconditionally. That means the flush
LSN (as reported by pg_last_wal_receive_lsn()) never moves backward, whereas
the write LSN might. Because of this difference in behavior, I was thinking that
we might need to track the maximum write LSN seen so far and have the function
return that value.

 
Can you please explain the scenarios in which the record pointer of the WAL record written
by the receiver can move backwards.
For example, in physical replication, the WAL records are sent after a Flush on the primary in ascending
order of XLogRecPtr. They are also received in that order and written as they arrive by the receiver.
Are you referring to crash scenarios where unflushed WAL may be discarded and receiver has 
to move backwards and start from the last flushed record on the standby?

Thank you,
Rahila Syed

pgsql-hackers by date:

Previous
From: shveta malik
Date:
Subject: Re: Improve pg_sync_replication_slots() to wait for primary to advance
Next
From: vignesh C
Date:
Subject: Re: Logical Replication of sequences