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 1jv0fw-0006bW-0o for pgsql-general@arkaria.postgresql.org; Mon, 13 Jul 2020 15:47:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jv0fv-00034p-0Y for pgsql-general@arkaria.postgresql.org; Mon, 13 Jul 2020 15:47:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jv0fu-00034a-PS for pgsql-general@lists.postgresql.org; Mon, 13 Jul 2020 15:47:26 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jv0fs-0003L7-Ar for pgsql-general@lists.postgresql.org; Mon, 13 Jul 2020 15:47:25 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 088755F79F; Mon, 13 Jul 2020 11:47:22 -0400 (EDT) Date: Mon, 13 Jul 2020 11:47:22 -0400 From: Stephen Frost To: Paul =?iso-8859-1?Q?F=F6rster?= Cc: James Sewell , "pgsql-generallists.postgresql.org" Subject: Re: Safe switchover Message-ID: <20200713154722.GU12375@tamriel.snowman.net> References: <7E43945E-4571-4D30-9E8F-B940B9277DEF@gmail.com> <20200710152959.GK12375@tamriel.snowman.net> <01BE6868-6920-4E5D-9A4D-838E3036DCD2@gmail.com> <20200710154556.GL12375@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="qpPEP5KwiTnADq8L" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --qpPEP5KwiTnADq8L Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Paul F=F6rster (paul.foerster@gmail.com) wrote: > > On 10. Jul, 2020, at 17:45, Stephen Frost wrote: > > Sure, if you know exactly why the former primary failed and have > > confidence that nothing actually bad happened then pg_rewind can work > > (though it's still not what I'd generally recommend). > >=20 > > If you don't actually know what happened to the former primary to cause > > it to fail then I definitely wouldn't use pg_rewind on it since it > > doesn't have any checks to make sure that the data is actually > > generally consistent. These days you could get a bit of a better > > feeling by running pg_checksums against the data dir, but that's not > > going to be as good as doing a pgbackrest delta restore when it comes to > > making sure that everything is valid. >=20 > we use Netapp plus continuous archiving. To protect agains block corrupti= on, all our database clusters have been created with initdb -k. So they sho= uld report block corruptions in the log. I certainly encourage using initdb -k. > The usual reason why a database cluster goes down is because the server i= s shut down which initiates a switchover and is not problematic. If the ser= ver goes down by a power outage, system crash or similar, then an automatic= failover is initiated, which, according to our experience, is also not pro= blematic. Patroni seems to handle both situations well. Sure, Patroni will handle the failover fine- but that's not what I was referring to. If the server crashes and you have no idea why or what happened, I would strongly recommend against using pg_rewind to rebuild it to be a replica as there's no validation happening- you might failover to it much later and, if you're lucky, discover quickly that some blocks had gotten corrupted or if you're unlucky not discover until much later that something was corrupted when the crash happened. Using initdb -k is good, but PG is only going to check the block when it goes to read it, which might not be until much later especially on a system that's been rebuilt as a replica. > The worst case is, that both servers crash, which is pretty unlikely. So,= the worst case is that we have to perform a volume restore with Netapp and= replay the WAL files since that last snapshot. Should the replica database= cluster be damaged too, then we may need to reinit it with Patroni. This i= s acceptable even for large database clusters because replication runs fast= =2E But the possibility is very, very small. This seems like an independent question and I'm not really sure what is meant here by 'reinit it with Patroni'. > So, in my opinion, -k should be default and if one wanted to create a non= -checksummed database cluster, it would have to be stated on the command li= ne explicitly. This IMHO is a reasonable way to make people migrate to chec= ksums over time as database clusters are migrated. I agree that it'd be good to have -k on by default. Thanks, Stephen --qpPEP5KwiTnADq8L Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJfDIIKAAoJEO1sijiDR2RVI4wP/jw8mZ7dHvI3A07ktoKW+mru amt7/02OQq+N5T410Az53+2q1h9cCylmmUsj7rT6CWc3V4dPB7BFw740yFKIXfkS ryayT5MQRYzlGdG6fBIe/RTW5AeJ2W+O+creytwjnL6WkTTWzOBCJbAXiS8VcXrL NxSuRaxYqSi7r89xv+pSVoE4URYHwzpTGMasBHtaZz8fI9g83Nb4Nh0+KtZb4wWr tJwGW+MmXv2BBSOgBlsnRTdGvg5+huKGyhfukYtQi6CHIgEc1PACKC4XlHYoh1CA V/BjgYo7ox/56f8J0P7dV3zEpfqp6KveVj7/HJGYRf3Fr3WAuDRCaXVi7eOuk00m 8ZG2SuUBXLP/xEM7uFFW1SyDNKkRikD+psjIXPHf0+heobWE+fQLSsxzfAenXUux J/IaqOKzbq4FpSkzGGAaliIrV3astnkcaH7sUNS0f/5ln49DDdaXPbe9asxaAY12 DSM1d3ZdYzXSIHdXqZA3UJoDTzpzzrkq23S/IrL7NdrpUh83vAmYDXuPO78+CFFd vKmxRmLNaFeqVYRRKGOZS00qj/uP46hpBJgQrGAuV8+8frGDHrV7/aeA+kZn4KYp n1Uqcg5zKCRoRtBVajHnzidysxTzdOXxAZmnOtsel7hbnGocVHgKlmEWp5QKfLV7 TPnj9SfGqCdoUbBMW+Es =omjL -----END PGP SIGNATURE----- --qpPEP5KwiTnADq8L--