Обсуждение: Notify When Streaming Replication Failover Occurred (slave promoted to master).

Поиск
Список
Период
Сортировка

Notify When Streaming Replication Failover Occurred (slave promoted to master).

От
"Avi Weinberg"
Дата:

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.

 

Thanks!

IMPORTANT - This email and any attachments is intended for the above named addressee(s), and may contain information which is confidential or privileged. If you are not the intended recipient, please inform the sender immediately and delete this email: you should not copy or use this e-mail for any purpose nor disclose its contents to any person.

Re: Notify When Streaming Replication Failover Occurred (slave promoted to master).

От
Dave Cramer
Дата:

On Sun, 13 Jun 2021 at 19:32, Avi Weinberg <AviW@gilat.com> 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.

 


On the surface this seems like a great idea, however contemplating this a bit more; where would the signal come from ? Currently the only option I can think of is to send a NOTIFY. 
It seems to me that the Patroni code is a better place to do this from.

Dave

Re: Notify When Streaming Replication Failover Occurred (slave promoted to master).

От
"Peter J. Holzer"
Дата:
On 2021-06-14 08:10:58 -0400, Dave Cramer wrote:
> On Sun, 13 Jun 2021 at 19:32, Avi Weinberg <AviW@gilat.com> wrote:
>
>
>     I need to take actions when Postgres streaming replication failover
>     occurred.  Is there a way to be notified when Postgres slave becomes
>     master?
>
> On the surface this seems like a great idea, however contemplating this a bit
> more; where would the signal come from ? Currently the only option I can think
> of is to send a NOTIFY. 
> It seems to me that the Patroni code is a better place to do this from.

I agree. That is something Patroni should do, not the database. Maybe
Patroni could be extended to invoke a script after taking some action.

I know of one program (vip_manager) which monitors patroni state and
takes action (enable/disable virtual ip addresses) - that one checks the
distributed database (etcd or whatever) periodically, AFAIK.

        hp

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

Вложения