pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedNotify When Streaming Replication Failover Occurred (slave promoted to master).
5+ messages / 3 participants
[nested] [flat]
* Notify When Streaming Replication Failover Occurred (slave promoted to master).
@ 2021-06-13 08:00 Avi Weinberg <AviW@gilat.com>
0 siblings, 1 reply; 5+ messages in thread
From: Avi Weinberg @ 2021-06-13 08:00 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
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.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Notify When Streaming Replication Failover Occurred (slave promoted to master).
@ 2021-06-13 15:51 Peter J. Holzer <hjp-pgsql@hjp.at>
parent: Avi Weinberg <AviW@gilat.com>
0 siblings, 0 replies; 5+ messages in thread
From: Peter J. Holzer @ 2021-06-13 15:51 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Notify When Streaming Replication Failover Occurred (slave promoted to master).
@ 2021-06-13 23:31 Avi Weinberg <AviW@gilat.com>
0 siblings, 1 reply; 5+ messages in thread
From: Avi Weinberg @ 2021-06-13 23:31 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
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.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Notify When Streaming Replication Failover Occurred (slave promoted to master).
@ 2021-06-14 12:10 Dave Cramer <davecramer@postgres.rocks>
parent: Avi Weinberg <AviW@gilat.com>
0 siblings, 1 reply; 5+ messages in thread
From: Dave Cramer @ 2021-06-14 12:10 UTC (permalink / raw)
To: AviW@gilat.com; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
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
>
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Notify When Streaming Replication Failover Occurred (slave promoted to master).
@ 2021-06-16 08:08 Peter J. Holzer <hjp-pgsql@hjp.at>
parent: Dave Cramer <davecramer@postgres.rocks>
0 siblings, 0 replies; 5+ messages in thread
From: Peter J. Holzer @ 2021-06-16 08:08 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
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!"
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2021-06-16 08:08 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-06-13 08:00 Notify When Streaming Replication Failover Occurred (slave promoted to master). Avi Weinberg <AviW@gilat.com>
2021-06-13 15:51 ` Peter J. Holzer <hjp-pgsql@hjp.at>
2021-06-13 23:31 Notify When Streaming Replication Failover Occurred (slave promoted to master). Avi Weinberg <AviW@gilat.com>
2021-06-14 12:10 ` Dave Cramer <davecramer@postgres.rocks>
2021-06-16 08:08 ` Peter J. Holzer <hjp-pgsql@hjp.at>
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