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 1gw3Je-00012T-U4 for pgsql-general@arkaria.postgresql.org; Tue, 19 Feb 2019 11:11:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gw3Jd-0001fv-KY for pgsql-general@arkaria.postgresql.org; Tue, 19 Feb 2019 11:11:57 +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 1gw3Jd-0001fR-97 for pgsql-general@lists.postgresql.org; Tue, 19 Feb 2019 11:11:57 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gw3JZ-0003bv-Jf for pgsql-general@lists.postgresql.org; Tue, 19 Feb 2019 11:11:55 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id CEAC85F79E; Tue, 19 Feb 2019 06:11:52 -0500 (EST) Date: Tue, 19 Feb 2019 06:11:52 -0500 From: Stephen Frost To: =?iso-8859-1?Q?Mart=EDn_Fern=E1ndez?= Cc: "pgsql-generallists.postgresql.org" Subject: Re: PG Upgrade with hardlinks, when to start/stop master and replicas Message-ID: <20190219111152.GJ6197@tamriel.snowman.net> References: <5c6b0bc5828e9f3dde000002@polymail.io> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="HcLgruZUVNEEX12n" Content-Disposition: inline In-Reply-To: <5c6b0bc5828e9f3dde000002@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 --HcLgruZUVNEEX12n 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: > After reading the pg_upgrade documentation multiple times, it seems that = after running pg_upgrade on the=A0primary=A0instance, we can't start it unt= il we run rsync from the=A0primary=A0to the=A0standby. I'm understanding th= is from the following section in the pg_upgrade manual page. >=20 > ``` > You will not be running pg_upgrade on the standby servers, but rather rsy= nc on the > =A0 =A0 =A0 =A0 =A0 =A0primary. Do not start any servers yet. > ``` >=20 > I'm understanding the `any` as=A0primary=A0and=A0standbys. Yes, that's correct, you shouldn't start up anything yet. > On the other hand, we've been doing tests that start the=A0primary=A0inst= ance as soon as pg_upgrade is done. This tests have worked perfectly fine s= o far. We make the rsync call with the=A0primary=A0instance running and the= =A0standby=A0can start later on after rsync is done and we copy the new con= figuration files. This is like taking an online backup of the primary without actually doing pg_start_backup / pg_stop_backup and following the protocol for that, meaning that the replica will start up without a backup_label and will think it's at whatever point in the WAL stream that the pg_control file says its at as of whenever the rsync copies that file. That is NOT SAFE and it's a sure way to end up with corruption. The rsync while everything is down should be pretty fast, unless you have unlogged tables that are big (in which case, you should truncate them before shutting down the primary) or temporary tables left around (which you should clean up) or just generally other things that a replica doesn't normally have. If you can't have any downtime during this process then, imv, the answer is to build out a new replica that will essentially be a 'throw-away', move all the read load over to it and then go through the documented pg_upgrade process with the primary and the other replicas, then flip the traffic back to the primary + original replicas and then you can either throw away the replica that was kept online or rebuild it using the traditional methods of pg_basebackup (or for a larger system, you could use pgbackrest which can run in parallel and is much, much faster than pg_basebackup). > If what we are doing is wrong, we need to run `rsync` before starting the= primary=A0instance, that would mean that the primary and the=A0standby=A0a= re not usable if pg10 doesn't start correctly in the primary right ?=A0 This is another reason why it's good to have an independent replica, as it can be a fail-safe if things go completely south (you can just promote it and have it be the primary and then rebuild replicas using the regular backup+restore method and figure out what went wrong with the pg10 migration). Thanks! Stephen --HcLgruZUVNEEX12n Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJca+R4AAoJEO1sijiDR2RVhk0QAI9wF/uP08n4wXhBN/EJNn4e EIcYJltf6f7rXldwljFMNXeZpgeD86+af0nywLQnHwGXxRUVrcxMzDSWpNgdYZBE l0fPoGhI4JyRbToWL4wdAuWJm8kUbj6quz5anZTSOsNdAQIl1jsGyhAAYupS7V+i Q11UNXHBtMBkBLLNsu1tlk2s8MqcCZsStFG+93v9pIaHYwqh2M9GnwL2JBr82YVH z1P6/MfO5FsEMaldiapNEuAOUaHtH3wwCm9bygzrsAuEHmthY1Fv6qf/7pWn9L6g GlENTsl7UpLeu1+7/MAOSJhdl9gJmrREau+oSOySYvPdZuWh80cBJpD/r+Wc3rmC pAZehk9G9WYmGkVkHz8lmC8+e8Vl1RVqdzVI569nXlpvccbxi16TjipVd+JzfH6i h5PUqGFlumRhf/3oerbYaH64OrlxdqsxFoK+Qqxo3yqmtF1Ln8e7s164jraybg+c 1BCvJNSP/R5LTcxCv2/Y/aRsD2oVxW5IDYfDn52BpbwHtkwUY8XeCH2fjyaTB8/q 24ikTlJ+yQa07zm9I4KGLtOY5aJNVSKCoPe5YhFPwFzzH1xyXMFmU/oFNS2C/ERC mO8vk0JbbvUo5s36Nrf53G2XGPOyPYZeHnefxxuX0dHxv1obYaRJPhuLs90rJToX JdGVUWwM5MDnjhKzZdFZ =tHfr -----END PGP SIGNATURE----- --HcLgruZUVNEEX12n--