Re: Allow reading LSN written by walreciever, but not flushed yet

From: Rahila Syed <rahilasyed90(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Cc: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Allow reading LSN written by walreciever, but not flushed yet
Date: 2025-10-06 06:16:19
Message-ID: CAH2L28st0ajc1k6y8CH2aTPVXd+kdPSm_6b+9VFGVx-6XMuTFw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2025-10-06 06:19:52 Re: Logical Replication of sequences
Previous Message shveta malik 2025-10-06 06:12:46 Re: Improve pg_sync_replication_slots() to wait for primary to advance