You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Physical replication reports the server's WAL end as the write position #6697
In physical replication, Npgsql sends LastReceivedLsn as the write position of its standby status updates (ReplicationConnection.cs:626-630), and sets it to the WalEnd field of each XLogData message and of each keepalive (:481-484, 517-518). An XLogData message's WalEnd is how far the server's WAL extends, not the end of the data in the message (postgres walsender.c:3611-3612), while walreceiver reports the end of what it has written (postgres walreceiver.c:945-952, 1064, 1256-1263).
So pg_stat_replication.write_lsn shows WAL as written before it reached the client. With the client in synchronous_standby_names and synchronous_commit = remote_write, the primary can confirm a commit before its WAL arrived. Also, LastReceivedLsn is never reset when a new stream starts, so it keeps the highest position of earlier streams, which is wrong when the next one starts lower, e.g. on a restart from the last flushed position after a cancel (nothing resets it, and it only increases, :481-484, 517-518).
Logical XLogData messages aren't affected by the WalEnd problem: their WalEnd is their start position (postgres walsender.c:1642-1643). The missing reset affects logical streams too. The same code is on the 8.0, 9.0 and 10.0 hotfix branches.
Activity