Hi Ahmed, Can you please elaborate? One way I found to check the time lag is this: postgres=# SELECT CASE WHEN pg_last_wal_receive_lsn() = pg_last_wal_replay_lsn() THEN 0 ELSE EXTRACT (EPOCH FROM now() - pg_last_xact_replay_timestamp()) END AS log_delay; What I want to understand is that, in case of replication link failure, there will still be inserts happening at the master node. In that case, how will the slave know if it is up-to-date? Regards, Mariya From: "Ahmed, Nawaz (Fuji Xerox Australia)" <Nawaz.Ahmed@xxxxxxxxxxxxxxxxx> Hi, You could achieve that with a combination of those functions and querying the pg_stat_replication on either side of your setup. Regards, Nawaz Ahmed Database Administrator |
P: 02 9856 5337 | E: Nawaz.Ahmed@xxxxxxxxxxxxxxxxx
| W: www.fujixerox.com.au
| From: Mariya Rampurawala <Mariya.Rampurawala@xxxxxxxxxxx>
Hi, I am working on providing HA for replication, using automation scripts. My set up consists of two nodes, Master and Slave. When master fails, The slave is promoted to master. In case of sync replication, we do not check if the data is up-to-date on slave. But in case of async replication, how can we check if the slave is up-to-date. One way I found from the blogs is to compare the values of pg_last_wal_receive_lsn()
and pg_last_wal_replay_lsn() If these values are same, can we say that the slave is up-to-date? Both these values I will fetch from the slave node. How will
the slave ensure it is up-to-date, if the network between master and slave is broken? Regards, Mariya
|