Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ltQan-0002gx-8u for pgsql-general@arkaria.postgresql.org; Wed, 16 Jun 2021 08:08:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ltQam-0006KZ-0A for pgsql-general@arkaria.postgresql.org; Wed, 16 Jun 2021 08:08:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ltQal-0006JA-ND for pgsql-general@lists.postgresql.org; Wed, 16 Jun 2021 08:08:07 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ltQai-0003rk-Cv for pgsql-general@lists.postgresql.org; Wed, 16 Jun 2021 08:08:06 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id BF95C4E45; Wed, 16 Jun 2021 10:08:02 +0200 (CEST) Date: Wed, 16 Jun 2021 10:08:02 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: Notify When Streaming Replication Failover Occurred (slave promoted to master). Message-ID: <20210616080802.GA26107@hjp.at> Mail-Followup-To: pgsql-general@lists.postgresql.org References: <000001d760ac$38ea9ca0$aabfd5e0$@gilat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="9amGYk9869ThD9tj" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --9amGYk9869ThD9tj Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2021-06-14 08:10:58 -0400, Dave Cramer wrote: > On Sun, 13 Jun 2021 at 19:32, Avi Weinberg wrote: >=20 >=20 > I need to take actions when Postgres streaming replication failover > occurred.=A0 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.=A0 > 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 --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --9amGYk9869ThD9tj Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmDJsV4ACgkQ8g5IURL+ KF1xNhAAlzvEl7sTav/pV6ZM1FOWN/cC+pjT5/ZubvJ+8cKWKJ50v9iIyT3cYKqt o5d/RCJWxIeNMMQvI0F5u8vVCMXx0nXqMwQQmjj9Qd4i3sEvKqfoWmTXFB6PPFL8 5Uj3oCJWZdVIyIoAB/HbXQqXhkt8Vb/ci4A5dk5RVBcigp5U+6pGfbJ8ArSdMF8h FrmePz9RYT3BnT4UjwMxIE5iXrlulnM/X1SiLcjJwvaW3bf1Q/CjS44pN4dbU6qq Y8ZL3T7+FsNXaKosz+HXlWOwvysMgyYLqdAurppkrwIY3ttUHCyUAz5GVmAyQmOq lujBsjFMwy4cQTMJbb5QjvF6ibZ7sDLVU0dTGha4ZH8a6qncdt8P3+4VKgN5GTNE 6v/nmgKAbRUvoEkDXPVKSIRGw0K7W3nmjaCEs4AmKpcHntfcAgwLl/ATJwdsSuik Ls4opCxi3B2jV9KRu+q8rBOhN0VJrPh4Ixh5qK3daMAe4/t6Z2DS7+sc+RgnWQn8 emm/kACFsjtKb9biK3xEsxCILXBZfm6aWnPxLIqjvAfBZSIwKHp61dynsS/CdxEu bksR5uAMo3nq8gOnlYQD/tYdlWo2YeW+P2alUUcTO8OkUpzPz7YUbyq6QyMqrycR IQyHhsB15MZt2r1PTFOAWx1uiB/ZR/nF5hCU87hRwx03wS9P30o= =Z2HU -----END PGP SIGNATURE----- --9amGYk9869ThD9tj--