Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1frpes-0002Cg-HI for pgsql-general@arkaria.postgresql.org; Mon, 20 Aug 2018 19:16:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1frpep-0006Ct-NP for pgsql-general@arkaria.postgresql.org; Mon, 20 Aug 2018 19:16:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1frpep-0006Cd-EO for pgsql-general@lists.postgresql.org; Mon, 20 Aug 2018 19:16:07 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1frpeT-0004GM-1Z for pgsql-general@postgresql.org; Mon, 20 Aug 2018 19:16:05 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id AF5B05F79C; Mon, 20 Aug 2018 15:15:43 -0400 (EDT) Date: Mon, 20 Aug 2018 15:15:43 -0400 From: Stephen Frost To: bricklen Cc: edmundo@sw-argos.com, pgsql-general@postgresql.org Subject: Re: upgrading from pg 9.3 to 10 Message-ID: <20180820191543.GU3326@tamriel.snowman.net> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Epmur3l+A7twAlqw" 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 --Epmur3l+A7twAlqw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * bricklen (bricklen@gmail.com) wrote: > On Tue, Aug 14, 2018 at 10:45 AM Edmundo Robles > wrote: > > Is safe to upgrade from pg 9.3 to pg 10 directly using pg_upgrade or > > is better upgrade, with pg_upgrade, from 9.3 -> 9.4 ->9.5 -> 9.6 -> 1= 0. >=20 > Using pg_upgrade, it is definitely possible to upgrade 9.3 to 10 in one > jump. We did this in production earlier this year for 1500 Postgres > clusters. > At https://bricklen.github.io/2018-03-27-Postgres-10-upgrade/ I documented > (in excrutiating detail, perhaps) how we upgraded those clusters from 9.3 > to 10 with sub-15 minute downtime per cluster. The only real issues we ran > into were some corrupted indexes that appeared to be related to 10.1 and > 10.2. Upgrading to 10.3/10.4 and reindexing fixed those particular > corrupted indexes. Interesting write-up. A few points: #1: I'd strongly recommend including something in the write-up about checking for unlogged tables. Those can add quite a bit of time to the rsync if they aren't truncated before the primary cluster is shut down. #2: The issue with timelines leads me to suspect that you had a restore_command defined and that when PG started up, it found the timeline history files from the old cluster. If you don't have a restore_command set for any of these then I'm very curious what happened. The other possibility (though I wouldn't have expected a timeline complaint from PG...) is that the replica wasn't fully up to date for whatever reason. #3: There's a number of checks discussed in the upgrade documentation around using the rsync-based method, but it doesn't seem like you did those. A mention of them might be good. Note that these are particularly important because the rsync will *not* copy over changes to the data files except in the relatively rare case of the relfilenode's size changing (given that most of them are 1G, that's not too likely). The note you have about the rsync taking more time due to "if the remote replica was fully caught up when it was shut down" isn't accurate- there is no WAL replay that happens on the replica using this method to 'catch up' and if WAL replay was required to have this process be correct then it simply wouldn't ever work. #4: pg_upgrade absolutely resets the timeline to '1', and you shouldn't ever copy over history files from the old cluster to the new cluster. The new replicas will *also* be on timeline '1'. #5: There's no such thing as a 'timeline decrement'. The new cluster (either on the primary or the replica) should only ever see itself as being on timeline '1' when starting up after the pg_upgrade and before a promotion happens. #6: In note 33, it's unclear what this is referring to. There's no WAL which would have been generated by the pg_upgrade (that process is not WAL'd). Perhaps some activity needed to be done on the primary before a new restorepoint would happen on the replica, due to how pg_basebackup needs a restorepoint to begin from when working on a replica. Thanks! Stephen --Epmur3l+A7twAlqw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJbexNfAAoJEO1sijiDR2RVDocP/jF4sVrw2bTIp9tOaauVuQCc swarQ2Aw2S0E81d/moyK/y5wBiW7gNDPMqGzdw3gX0WilxRk5OaWN/9odWJjyX+j wZXDpBQfIX82pUmHYA7mnMcZg6DjBS55uNUk1AUkqTMk29jnXdFuBBRV7bym/m4H U34NGO9H/Ek4cCbFmL5TDFcvRS2e+fy6WCElZ/bg8xlWV9mY/9RaG0e7ivatlsu0 2qkdFJy7HiECjn3khFgvIED3+9eohtpFmM2AP2BWNgQCxtmz21kggk0lB4t5hP5c rSe9onOuH5KIqX/KgvxPnBCS0CDhO/ihxbk3DLxJkJofsnSf3RWQPjOoAm3mCWAl VqOv0PJgFgQrBTSU9lIfqJw00p9BMAe4fpp9RXBubNKOUfFNzb52Bpr24C6muijC CGQ1ZIdP1dM/n94L7P25RACncrZGPFDp2qDW2S0tlVz0XRBuJScfrH/rix7xt1YC okBOsBL5IZP5qBOUGuhGxZ7om46YCrVVJWEB8FJy16kh9ZoxMKBdusEIKMOc3DaZ ripwlSwWL+WlRoybRDuleI/8gS2imPH/jII2wFSh2pEGniLWnRu7QlNwayN5DGG5 ilsxaZe4a6MdO34jZLmv59ds3BMgM7Us++xVGrFoNY9Fnn8OU7XC518RyCDFCP+X ggh+6RPeIJXxlxz2Qe5N =9o2Q -----END PGP SIGNATURE----- --Epmur3l+A7twAlqw--