A customer of ours complained that if you have an inactive primary,
monitoring the apply lag on a standby reports monotonically increasing
lag. The reason for this is that the apply lag is only updated on
COMMIT records, which of course don't occur in inactive servers.
But CHECKPOINT records do occur, so the WAL insert pointer continues to
move forward, which is what causes the spurious lag.
(I think newer releases are protected from this problem because they
don't emit checkpoints during periods of inactivity. I didn't verify
this.)
This patch fixes the problem by using the checkpoint timestamp to update
the lag tracker in the standby. This requires a little change in where
this update is invoked, because previously it was done only for the XACT
rmgr; this makes the patch a little bigger than it should.
--
Álvaro Herrera PostgreSQL Expert, https://www.2ndQuadrant.com/