Re: Does having pg_last_wal_replay_lsn[replica] >= pg_current_wal_insert_lsn[master] guarantee that the replica is caught up? - Mailing list pgsql-hackers

From Dmitry Koterov
Subject Re: Does having pg_last_wal_replay_lsn[replica] >= pg_current_wal_insert_lsn[master] guarantee that the replica is caught up?
Date
Msg-id CA+CZih7Q5cghTYSFCwC_kNGLSx1jWC4w3=UgJz0mO5A_JYnfvA@mail.gmail.com
Whole thread Raw
In response to Re: Does having pg_last_wal_replay_lsn[replica] >= pg_current_wal_insert_lsn[master] guarantee that the replica is caught up?  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
List pgsql-hackers
Thank you for the detailed explanation!

I doubt many people from -general would actually be able to provide such info since the spirit of that list is to find work-arounds for problems and questions at user level rather than dig into the details on how something actually works.

It's worth adding to the documentation, with that exact example BTW:
(I can try submitting a docs PR if you think it's a good idea).

Also, when I said that we use PQexec, I did it just for an illustration: in practice we use the node-postgres JS library which sends multi-statement protocol messages. So - transaction wise - it works the same way as PQexec with multiple queries, but it returns responses for ALL queries in the batch, not just for the last one (very convenient BTW, saves on network round-trip latency). This mode is fully supported by PG wire protocol: https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-FLOW-MULTI-STATEMENT


On Wed, Aug 3, 2022 at 12:32 AM Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote:

<snip> 
 
=# select pg_current_wal_insert_lsn();
 pg_current_wal_insert_lsn
---------------------------
 0/68E5038
(1 row)
=# insert into t values(0)\; select pg_current_wal_lsn();
INSERT 0 1
 pg_current_wal_lsn
--------------------
 0/68E5038
(1 row)
=# select pg_current_wal_insert_lsn();
 pg_current_wal_insert_lsn
---------------------------
 0/68E50A0
(1 row) 
 
<snip>

=# select pg_current_wal_insert_lsn();
 pg_current_wal_insert_lsn
---------------------------
 0/68E75C8
(1 row)
=# begin\;insert into t values(0)\;commit\; select pg_current_wal_lsn();
 pg_current_wal_lsn
--------------------
 0/68E7958

pgsql-hackers by date:

Previous
From: "Shinoda, Noriyoshi (PN Japan FSIP)"
Date:
Subject: RE: Improve logging when using Huge Pages
Next
From: Alvaro Herrera
Date:
Subject: Re: PostgreSQL 15 minor fixes in protocol.sgml