Re: Strange decreasing value of pg_last_wal_receive_lsn() - Mailing list pgsql-hackers

From godjan •
Subject Re: Strange decreasing value of pg_last_wal_receive_lsn()
Date
Msg-id C1BDB628-A26D-4D14-A481-341A239089B7@gmail.com
Whole thread Raw
In response to Re: Strange decreasing value of pg_last_wal_receive_lsn()  (Sergei Kornilov <sk@zsrv.org>)
Responses Re: Strange decreasing value of pg_last_wal_receive_lsn()  (Michael Paquier <michael@paquier.xyz>)
Re: Strange decreasing value of pg_last_wal_receive_lsn()  (Jehan-Guillaume de Rorthais <jgdr@dalibo.com>)
List pgsql-hackers
I got it, thank you.
Can you recommend what to use to determine which quorum standby should be promoted in such case?
We planned to use pg_last_wal_receive_lsn() to determine which has fresh data but if it returns the beginning of the segment on both replicas we can’t determine which standby confirmed that write transaction to disk.

On 8 May 2020, at 14:50, Sergei Kornilov <sk@zsrv.org> wrote:

Hello

Yes, this is expected. Walreceiver always start streaming from beginning of the wal segment.
./src/backend/replication/walreceiverfuncs.c in RequestXLogStreaming:

* We always start at the beginning of the segment. That prevents a broken
* segment (i.e., with no records in the first half of a segment) from
* being created by XLOG streaming, which might cause trouble later on if
* the segment is e.g archived.

regards, Sergei

pgsql-hackers by date:

Previous
From: Sergei Kornilov
Date:
Subject: Re: Strange decreasing value of pg_last_wal_receive_lsn()
Next
From: Matt Daw
Date:
Subject: Re: Improving estimates for TPC-H Q2