Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5kVZ-0008K0-17 for pgsql-general@arkaria.postgresql.org; Mon, 18 Mar 2019 05:08:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h5kVU-0005IF-Oq for pgsql-general@arkaria.postgresql.org; Mon, 18 Mar 2019 05:08:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5kVU-0005I7-D6 for pgsql-general@lists.postgresql.org; Mon, 18 Mar 2019 05:08:16 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h5kVR-0002k3-4e for pgsql-general@lists.postgresql.org; Mon, 18 Mar 2019 05:08:14 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 51BE25F7A2; Mon, 18 Mar 2019 01:08:12 -0400 (EDT) Date: Mon, 18 Mar 2019 01:08:12 -0400 From: Stephen Frost To: =?iso-8859-1?Q?Mart=EDn_Fern=E1ndez?= Cc: "pgsql-generallists.postgresql.org" Subject: Re: Upgrade standby after starting cluster using rsync Message-ID: <20190318050812.GB6197@tamriel.snowman.net> References: <5c86b376caab5331f9000001@polymail.io> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="a3TncSl96O4908Bf" Content-Disposition: inline In-Reply-To: <5c86b376caab5331f9000001@polymail.io> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --a3TncSl96O4908Bf Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Mart=EDn Fern=E1ndez (fmartin91@gmail.com) wrote: > I've wrote a couple of questions around pg_upgrade and updating standbys = using rsync last week. We were able to successfully upgrade half of our clu= ster (the other half was kept for failover) from pg92 with postgis 1.5.8 to= pg10 with postgis 2.4. It was a really interesting challenge because of po= stgis binary incompatibility for geometry data types. >=20 > The rsync call that we used looked exactly like this (taken from pg_upgra= de man page basically): >=20 > `rsync --verbose --verbose --progress --archive --delete --hard-links --s= ize-only=A0 --no-inc-recursive /var/lib/postgres/9.2 /var/lib/postgres/10 $= REPLICA_IP:/var/lib/postgres` >=20 > We are now in the journey of upgrading the other half of the cluster sinc= e we have concluded that the upgrade was successful.=A0 >=20 > We are planning on using the same rsync call to upgrade the rest of the s= tandbys (in combination with pg_start_backup/pg_stop_backup low level api).= My only concern is that I'm not 100% sure if the `--size-only` flag will b= e enough to guarantee that files are the same. On the initial set of standb= ys that we upgraded this shouldn't generate an issue since the standbys wer= e at the same last checkpoint than the master=A0 and we did the rsync call = before starting the primary (after running pg_upgrade). No, you can't use --size-only to rebuild those replicas while the primary is online, even if you're using pg_start/stop_backup, you should really enable the rsync checksums-based check to make sure that you're copying all of the files that you need to from the primary to the replica during the pg_start/stop_backup, and then you need to make sure and have an appropriate backup_label installed on all the replicas to get them to replay from the pg_start_backup checkpoint and to replay through to the end of the pg_stop_backup. You would have a recovery.conf file already but you might need to make sure it has a restore_command which can pull back WAL that might have already been archived by the primary. Note that this method of rebuilding the replicas will likely be time-consuming but unfortunately it's necessary. There are alternatives to using rsync to perform this if you need to get it done faster. > Is there any potential issues that could show up if we do it with --size-= only ? Should we use the default rsync mechanism that would check for size = and timestamps ? I wouldn't trust just size/timestamp in this case, you really should use checksums. > Hoping someone has some better experience than me on upgrading standbys u= sing rsync. The rsync-based pg_upgrade mechanism for replicas *only* works when it's done after all of the systems have been shut down and you've verified that all the nodes reached the same shutdown checkpoint, it is *not* appropriate for online rebuilding of replicas. Thanks! Stephen --a3TncSl96O4908Bf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJcjye7AAoJEO1sijiDR2RVJ6MP/3hUxWd+Az5SqhKIzFtsXZnO /Jwx3d+dQr0OQXqfwCXqEgAuJ7iGiXx9qjYpQSKQlhmXJruK2CSGzlaWqbYtpohR phS9udvbUpyq8s+SUG8nDfRWB1XyCQAFQXk6P7bYg7iMmqPFNRTjNRvBrg1xz/g0 2HKKcS3cphfI1fu+xZQVQEVShwla52QK1bB+rEfuncJFtdaC9Nl8ksvTMK1sfqwQ KdF3Rtbvap1IbcgQEFvQgXQ8u8uwTd7z/gB5/LgyMrXnmyYQAI8+FqzSaO43BwtP MpvFmoK1KJM4pb5z8dYdFMxv1Y3VTrNFZ2J6aJkNpoyo8KXb1BRMpWcncIUnqzh5 OoH+io1a7McFMdkhKmzDlBaI/qA7gMgVB95XtgILAOxNybTx09P2TsRFa8dnjbNS NA0lMtysG6PbfkAJyWci/pVRYU+sU9fV0PjawvCyy41G4oVB5yFQrc5TdX2NU1id bPOD3ToapbNS1wDEVMbZf2UmA3D0W01tcvj3fbPo/jwaCtzEw6r2ELNemN+QiKfS siYpE1D2ZsnkzqtFfublu0CgPYlHaVfOIprLcFzox9YQ+d2iDIBkfSOrIiN37kQs 9Nxdc8CHxLK+wGhH4Xzf/QpNnuFja/9x1lCMgfuBAqverRyP7R9efPSSvq8cSZNc 5yE4T9uFdQV2NzXW3coi =bmLp -----END PGP SIGNATURE----- --a3TncSl96O4908Bf--