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 1jv0sz-0007HW-Sy for pgsql-general@arkaria.postgresql.org; Mon, 13 Jul 2020 16:00:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jv0sy-0001Mj-RS for pgsql-general@arkaria.postgresql.org; Mon, 13 Jul 2020 16:00:56 +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 1jv0sy-0001Mc-KD for pgsql-general@lists.postgresql.org; Mon, 13 Jul 2020 16:00:56 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jv0sw-0004Qg-3a for pgsql-general@lists.postgresql.org; Mon, 13 Jul 2020 16:00:56 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 3072D5F79F; Mon, 13 Jul 2020 12:00:53 -0400 (EDT) Date: Mon, 13 Jul 2020 12:00:53 -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: <20200713160052.GV12375@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> <20200713154722.GU12375@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="WN2ELtqJJ9aZ3yHj" 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 --WN2ELtqJJ9aZ3yHj 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 13. Jul, 2020, at 17:47, Stephen Frost wrote: > >=20 > > 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. >=20 > I see your point, yet, I'm not sure how pgbackrest could protect us from = such a situation. A pgbackrest delta restore will scan the entire data directory and verify every file matches the last backup, or it'll replace the file with what was in the backup that's being used. If there's an error during any of that, the restore will fail. That re-validation of the entire data directory is a pretty huge difference compared to how pg_rewind works. > > This seems like an independent question and I'm not really sure what is > > meant here by 'reinit it with Patroni'. >=20 > reinit basically deletes the replica database cluster and triggers a new = full copy of the primary. You can either "patronictl reinit" or kill patron= i, rm -r ${PGDATA}, and start patroni. This is basically the same. Ah, yes, if you rebuild the replica from a backup (or from the primary), then sure, that's pretty similar to the pgbackrest delta restore, except that when using delta restore we're only rewriting files that have a different SHA checksum after being scanned, and we're pulling from the backup repo anything that's needed and not putting load on the primary. > > I agree that it'd be good to have -k on by default. >=20 > so, now, we're two. :-) Anyone else? ;-) There's been a few discussions on -hackers about this, that'd probably be the place to discuss it further.. Thanks, Stephen --WN2ELtqJJ9aZ3yHj Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJfDIU0AAoJEO1sijiDR2RV06QP/iCZU7yotS2XaVOuNeSTfvXY XE5xey9IRNSbZSyXcX4OnUVMBAiIpW2tvZT2LK8a/gQunEeq1+4VkGkOkwhBVJkD P5z9q8VWlvGhji00AHah5UUx6t+tloFsfJrVCW3puzNk+IImLilM9cA1ZbvWg8+A +jbhlDOKxHaFBY1xMvWvFCb3tgLG5p8CMy4hhcDxFLHXEBXu1oPdRTgFBer+Lrye FaXhDeS625wzAIztfaD63JxC97Juzqiv6jGPhJ+l8IztIFm3WH0mzk8UNa9KsJuW Ot3UcRZIL++RO7uE4E2vAmXv3xewI0+93HKED4xczSa1PPcvb0oLV9bvapX8g+RR +RHUKeI1xD5IMUYpQHKhgYJMNaRsI/YVxeM72o62pDfK/oZu+jyt+Pb6a1/gg1U5 aF3TNZkJbU57ofXO7rsjq19nbd5EsWyvldZP5ec3S52kGgxIArCEolcTF+VB8XmN nM+UByQQCVHFpkNtiO42ADjPqjp7uXna/Y26ddOxAIKOEUmbj/w0GyfYhcxcbAe8 T1u7LP/iw0zhTsHXt+NW9ywkbxjs/j67n7E3goTvfg00ktYL01P9POf59BwTVAp9 jp+s7o99EGh8WXg6BdAnqne52VCgfPMFcqXSVDDkNBtErJ/XJxi54at42Dzp/4Jw IUENC3dBIyha22tBtMx0 =ym4x -----END PGP SIGNATURE----- --WN2ELtqJJ9aZ3yHj--