pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: Notify When Streaming Replication Failover Occurred (slave promoted to master).
Date: Sun, 13 Jun 2021 17:51:21 +0200
Message-ID: <20210613155121.GA15132@hjp.at> (raw)
In-Reply-To: <DB9PR07MB7180CCBBE7BA7C900B583596CB329@DB9PR07MB7180.eurprd07.prod.outlook.com>
References: <DB9PR07MB7180CCBBE7BA7C900B583596CB329@DB9PR07MB7180.eurprd07.prod.outlook.com>

On 2021-06-13 08:00:24 +0000, Avi Weinberg wrote:
> I need to take actions when Postgres streaming replication failover occurred. 
> Is there a way to be notified when Postgres slave becomes master?  If no such
> notification possible, what is the best way to actively monitor which server is
> master.  My Postgres  is running inside Kubernetes and the HA is managed by
> Patroni.

I just do
    patronictl list -f yaml | grep -v 'Lag in MB'
periodically and send an email if the output changes. Of course instead
of sending an email the script could take any other action.

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (5+ messages)  latest in thread

Message-ID: <20210613155121.GA15132@hjp.at>
Permalink:  ../20210613155121.GA15132@hjp.at/
Also on:    postgresql.org/message-id/20210613155121.GA15132@hjp.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: hjp-pgsql@hjp.at
  Subject: Re: Notify When Streaming Replication Failover Occurred (slave promoted to master).
  In-Reply-To: <20210613155121.GA15132@hjp.at>
  References: <DB9PR07MB7180CCBBE7BA7C900B583596CB329@DB9PR07MB7180.eurprd07.prod.outlook.com> <20210613155121.GA15132@hjp.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox