Greetings,

We have the following setup:
A pg10 cluster with logical replication to a pg15 cluster, set up with the following query:
CREATE PUBLICATION "dbname_pub" FOR ALL TABLES;

We do an initial sync of DDL with pg_dump. The purpose of the replication is to perform an online upgrade with minimal downtime.

At the moment where we would switch to pg15 being the primary/lead we will stop writes to pg10; at that point we will validate that we are fully in sync, tear down pg10 and send writes to pg15. Our question is how we can validate our sync status. Given that there have been no DDL changes on pg10 (new tables, for instance), would the following check be sufficient?

Compare byte diff between WAL LSNs:
SELECT abs(pg_wal_lsn_diff(write_lsn, flush_lsn)) AS lag FROM pg_stat_replication;

If the byte diff is 0, I would assume that we're fully in sync. Is this understanding correct?

Another idea we've had would be to use CTID to fetch the last row (update/insert) in each table on both sides and compare row content, is this feasible? Is it safe to rely on CTIDs across logical replication?

best regards,
Robert Sjöblom

--
Innehållet i detta e-postmeddelande är konfidentiellt och avsett endast för adressaten.Varje spridning, kopiering eller utnyttjande av innehållet är förbjuden utan tillåtelse av avsändaren. Om detta meddelande av misstag gått till fel adressat vänligen radera det ursprungliga meddelandet och underrätta avsändaren via e-post


Reply via email to