Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tl1JL-008fJI-BW for pgsql-admin@arkaria.postgresql.org; Thu, 20 Feb 2025 07:49:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tl1JJ-002bHi-Dj for pgsql-admin@arkaria.postgresql.org; Thu, 20 Feb 2025 07:49:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tl1JH-002bHY-0L for pgsql-admin@lists.postgresql.org; Thu, 20 Feb 2025 07:49:29 +0000 Received: from resqmta-h2p-547392.sys.comcast.net ([2001:558:fd02:2446::4]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tl1JA-001vCv-03 for pgsql-admin@lists.postgresql.org; Thu, 20 Feb 2025 07:49:23 +0000 Received: from resomta-h2p-554993.sys.comcast.net ([96.102.179.194]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 256/256 bits) (Client did not present a certificate) by resqmta-h2p-547392.sys.comcast.net with ESMTPS id l1Iyt4Xmot8oel1IytpKV8; Thu, 20 Feb 2025 07:49:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=20190202a; t=1740037749; bh=L5sGa/oiC+ZVbXiDNQyPkWzW1BTcf/2HTVY/K1ofXfM=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: MIME-Version:Content-Type:Xfinity-Spam-Result; b=XXN7stJ/JxbsAUQ6PSgymk4Cuud6pbi4752vW9PfXovwHUsTByDnueQexZU7u9J3u 1Ml6Cusq3k28W4GYEs6bWAMsNfnvRjm6PticftKD3MXtxKN2jshMoA0abNzTsVvASu OWO+//yJnRZCdTe/S3Cqi+6650DbB24Rm4kaqpIALSXqhVPFIl4OFZXJerohefU4xl KU9MHsIq+SE+DCNArQ9YO4SQlOxGoZ0JykSRQxTjEBjakW53dWuC3L5hwThojma6Fw gA/uEsPMTpCvJRKJry30p+QgDWxbU3NoWjpQv3QyZPsKRib8BsKlqKzFJGsz5/vjrX iIFE3qkpfyPAw== Received: from Geralds-Laptop.local ([IPv6:2601:249:9280:4e70:3d3c:1cf5:e8d5:3425]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 256/256 bits) (Client did not present a certificate) by resomta-h2p-554993.sys.comcast.net with ESMTPSA id l1IttGVzLvJBVl1IvtXuaC; Thu, 20 Feb 2025 07:49:07 +0000 Received: by Geralds-Laptop.local (Postfix, from userid 501) id 6B4C779D995; Thu, 20 Feb 2025 01:49:03 -0600 (CST) From: Jerry Sievers To: richard@kojedz.in Cc: =?utf-8?Q?=C3=81lvaro?= Herrera , pgsql-admin@lists.postgresql.org Subject: Re: In-place upgrade with streaming replicas In-Reply-To: (richard@kojedz.in's message of "Wed, 19 Feb 2025 19:55:32 +0100") References: <202502191554.6asefyczl7jn@alvherre.pgsql> Date: Thu, 20 Feb 2025 01:49:03 -0600 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-CMAE-Envelope: MS4xfKK+HUFI23j2TvRxgx+UOqok7EPpANNhspPuFqiaBloJkilQ5ZZxS+9mQg4xB5Y7q8FfwEdn5p2n4tuSxYeUlOidBenR9uFxuvr7BIEMurB91D9yQX5P v0rs+nBsikHSPdNszpdxAbpOhJSm8Bouqhxbi6hsBr49QEnEraSBqUGysMzKNzDyy3eJx7MstictJLl9ugQy5ZHImm16LmGlfltnVOr8xHpzs5FKDBmPP1vd u9kLXzMb7N2YhLRxRxiLOSkQF1zjjrtmREZoOxrHao4BtgwnTEQGNYKBHk2nDb1iq9NIQpgq2WDt1ewlIwR6l+qCd8m4Aof7i7wHcg+4kwaqzbWGGgQQHj6z D18nWthP List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk richard@kojedz.in writes: > Dear Alvaro, > > Thanks for your answers. Unfortunately, I was unaware of a shutdown > record, that makes a difference then. So, I definitely must stop the > primary first, then use pg_controldata to obtain checkpoint > info. Then, can I query the replicas while they are up and running if > they've received the shutdown record or not? So, after shutting down > the primary, how will I know if a replica has received the mentioned > record, and is safe to shutdown? Hmmm, not sure about that but what we do, is stop primary, wait a $short time, then stop replicas... Then run pg_controldata on all nodes | filter out only the line indicating latest checkpoint and sort -u the output. Expect only a single line if all are matched. You may also wish to first insure that you got the same number of lines as total node count before doing the sorting and uniqueing. Very rarely on our huge systems, we'd have a mismatch after the verification in in those cases, our automated upgrade procedure restarts all nodes and then does the shutdown and verify check again. HTH > > Thanks for the clarifications. > > Best regards, > Richard > > 2025-02-19 16:54 id=C5=91pontban =C3=81lvaro Herrera ezt =C3=ADrta: >> On 2025-Feb-19, richard@kojedz.in wrote: >>=20 >>> With this, I have the question, that after the shutdown of primary, >>> what is >>> the guarantee for replicas having the same checkpoint location? Why >>> does the >>> order of shutting down the servers matter? What would be the really >>> exact >>> and reliable way to ensure that replicas will have the same checkpoint >>> location as the primary? >> The replicas can't write WAL by themselves, but they will replay >> whatever the primary has sent; by shutting down the primary first and >> letting the replicas catch up, you ensure that the replicas will >> actually receive the shutdown record and replay it. If you shut down >> the replicas first, they can obviously never catch up with the shutdown >> checkpoint of the primary. >> As I recall, if you do shut down the primary first, one potential >> danger >> is that the primary fails to send the checkpoint record before shutting >> down, so the replicas won't receive it and obviously will not replay >> it; >> or simply that they are behind enough that they receive it but don't >> replay it. >> You could use pg_controldata to read the last checkpoint info from >> all >> nodes. You can run it on the primary after shutting it down, and then >> on each replica while it's still running to ensure that the correct >> restartpoint has been created.