Re: AW: AW: AW: Replication Testing- How to introduce a Lag

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: "Subramanian,Ramachandran" <ramachandran(dot)subramanian(at)alte-leipziger(dot)de>, "pgsql-novice(at)lists(dot)postgresql(dot)org" <pgsql-novice(at)lists(dot)postgresql(dot)org>
Subject: Re: AW: AW: AW: Replication Testing- How to introduce a Lag
Date: 2026-03-23 14:33:29
Message-ID: 0e00fcc0062b59b88f98dba4900ce49d5a9a3fea.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Mon, 2026-03-23 at 05:55 +0000, Subramanian,Ramachandran wrote:
> Thank you so much for your guidance,  Today morning I noticed the columns being null . 
>
> > streaming | 0/491179E8 | 0/491179E8 | 0/491179E8 | 0/491179E8 |           |           |            |
>
> Does it make sense to use the below SQL as a primary health check ?
>
> [postgres(at)Source_server~]$ psql -p 5432 -c " select  pg_wal_lsn_diff(sent_lsn,replay_lsn) from pg_stat_replication"
>  pg_wal_lsn_diff
> -----------------
>                0
> (1 row)

No; you want to measure the lag between the primary's current WAL position and
what was already replayed on the standby:

SELECT pg_wal_lsn_diff(pg_current_wal_lsn(), replay_lsn)
FROM pg_stat_replication;

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Subramanian,Ramachandran 2026-03-23 16:36:22 AW: AW: AW: AW: Replication Testing- How to introduce a Lag
Previous Message hubert depesz lubaczewski 2026-03-23 10:56:19 Re: Old software