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 1lsSOU-0004kG-FZ for pgsql-general@arkaria.postgresql.org; Sun, 13 Jun 2021 15:51:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lsSOT-0007KA-FI for pgsql-general@arkaria.postgresql.org; Sun, 13 Jun 2021 15:51:25 +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 1lsSOT-0007K2-6i for pgsql-general@lists.postgresql.org; Sun, 13 Jun 2021 15:51:25 +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 1lsSOQ-00067S-9T for pgsql-general@lists.postgresql.org; Sun, 13 Jun 2021 15:51:24 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 0A2544DF5; Sun, 13 Jun 2021 17:51:21 +0200 (CEST) Date: Sun, 13 Jun 2021 17:51:21 +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: <20210613155121.GA15132@hjp.at> Mail-Followup-To: pgsql-general@lists.postgresql.org References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="nFreZHaLTZJo0R7j" 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 --nFreZHaLTZJo0R7j Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2021-06-13 08:00:24 +0000, Avi Weinberg wrote: > I need to take actions when Postgres streaming replication failover occur= red.=20 > 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 ser= ver 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 --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --nFreZHaLTZJo0R7j Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmDGKXMACgkQ8g5IURL+ KF2xNg/9FpUBipkejJk3mgX0v+Bz6wxGYp09l13CA77DEhaq6Bo4adIw+9P7PHQr XOmKi/sByjteybLZMjumfAH7NLhvxX6MlTuggpBYkqrmjghL5Ips4ZFNo1o128x2 V1HvrFVuNPEK1Oexr5yHYM+XwP51sHcA/ojndaCHnRV3Y59IXZECS0zRCbzb67en q/bb3PNgXA+DQclMmIefZ8W6MUWZNoQZHa1Ww01XIcsV0bbH3WyhGvdftaM3bOqY cXxhPYF0fEbbl9keY79AcyHykL66oAcT0mGBSglTsRY5wf7JyGbwn1CuxtWdmRTx YqehEyRb1Wvz/cPeGH192WfAOD8DS6pDfMNk/sTJSJJ1sRpz8C9FE1MdLT+0TOy+ Z+rtstGzP1zBZfrjtGtuRCNbxLw4bJT4/63mb43ry6PwgC1LqN0gLKt6PcmosxvS ODCUgnbYXh2w5ajAjpmPxGLLLt+rx+S3PxX2WapDS2gQrilRbydGABLmdEcB0Z33 4PxuBcYYCpnTd1nYh6l+1cbEHvOw3ahuJPJEhtI7qptMn1NWjfRw/IWzoDXZJkIr lLuA39JMsb/wCtYJOGukhRbhahnb85MRlMYZnJ3Y37WtW2NefgFRVNuoLvjgHZMw 9Bd4YM9M9pFmFjFyviaf3xCAR9ThGp27VwePJ0Z6SOJNnL9QfBA= =Dkui -----END PGP SIGNATURE----- --nFreZHaLTZJo0R7j--