Re: SQL command in Slave Database - Monitor Replication - Mailing list pgsql-admin

From Stuart Bishop
Subject Re: SQL command in Slave Database - Monitor Replication
Date
Msg-id CADmi=6OXXHsB04RdKdDAPbwEYau4oSRTTkTW7aTSvLahjbX7nw@mail.gmail.com
Whole thread Raw
In response to Re: SQL command in Slave Database - Monitor Replication  (Alberto Olivares <alberto.olivares@snowflakesoftware.com>)
List pgsql-admin
On 6 July 2015 at 15:35, Alberto Olivares
<alberto.olivares@snowflakesoftware.com> wrote:
> Hi Matheus,
>
>
> Thanks for your answer.  I do not have access to the primary database. So, I
> cannot run a SQL in there.
>
> I need to run the command in the Slave database that tells me whether the
> replication is still working or not.


"SELECT pg_last_xact_replay_timestamp()" gives you the time of the
last write. If it is not increasing, replication is broken or the
primary is idle. If it is NULL, the database is a primary or a
secondary just starting up. I think most of our are monitoring that
lag time is in a certain range - "SELECT (now() -
pg_last_xact_replay_timestamp()) < '5 minutes'::interval"



--
Stuart Bishop <stuart@stuartbishop.net>
http://www.stuartbishop.net/


pgsql-admin by date:

Previous
From: Alberto Olivares
Date:
Subject: Re: SQL command in Slave Database - Monitor Replication
Next
From: KhunSanAung
Date:
Subject: How to assign multiple-users to a Postgres database?