I'm running a fairly simple WAL streaming replication setup between two postgreSQL 9.3 servers that are on a private 1Gb LAN, but recently I've noticed that there is an increasing amount of replication delay:
# SELECT extract(epoch from now() - pg_last_xact_replay_timestamp()) AS slave_lag;
slave_lag
-----------
5.50896
The servers aren't particularly busy, so I was wondering what I could do to investigate this problem or possibly fix it.
Best Answer
Have you tried looking at:
The idea here is if both servers are synchronized, then there is no delay. If they are not synchronized, then display the delay.
One potential issue here is if PostgreSQL replication stops, this won't work properly, so you'd need to check periodically by some other mechanism to see if replication is running.