standby apply lag on inactive servers - Mailing list pgsql-hackers

From Alvaro Herrera
Subject standby apply lag on inactive servers
Date
Msg-id 20200110140828.GA6228@alvherre.pgsql
Whole thread Raw
Responses Re: standby apply lag on inactive servers
List pgsql-hackers
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/

Attachment

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: standby recovery fails (tablespace related) (tentative patch anddiscussion)
Next
From: Tom Lane
Date:
Subject: Re: our checks for read-only queries are not great