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 1qxcoz-002Ifu-W7 for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Oct 2023 00:41:30 +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 1qxcnz-00HIeF-K4 for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Oct 2023 00:40:27 +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 1qxcnx-00HIe7-W1 for pgsql-hackers@lists.postgresql.org; Tue, 31 Oct 2023 00:40:27 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qxcnp-003uK5-SZ for pgsql-hackers@lists.postgresql.org; Tue, 31 Oct 2023 00:40:25 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id AF9BF5C02B0; Mon, 30 Oct 2023 20:40:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 30 Oct 2023 20:40:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1698712815; x=1698799215; bh=i/ hFVfGOPHlSzgofnd5c2Qq2bUk0i76rBBVmIBCKqKM=; b=QMwsrcZsQKNRb75jZb izpQyRLQDM0Mj62NezMGfo5CXE223pPZc1QWCbukphoSaMG779614eAZ5JK79Yx6 7YA22t+jy3TaL2pajFgdW3QLdMu7mFgE7tUdvtOT+REeBLEei28zm1Ku7xz6PzpN 2rdatshRjcKugBTyWTfkq7/84JBUFSCRtQsz6KOS81JJSd5niiw/fAV/wPk3/aF7 fBWbVd2RY3QuesUiOwenWK2tM3lqLHlQazqiONQya2m86HB3jYpwrlcFXS49Gwyy zioCsVIqOr1vtZc+RCxgU4tIyogtPYp/0Viz9re6+l9zfLDyC/BjFGUM9/voX3X9 4g3A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1698712815; x=1698799215; bh=i/hFVfGOPHlSz gofnd5c2Qq2bUk0i76rBBVmIBCKqKM=; b=in8nIk9rk5WKgSURXlNZJs475nbsa HCfOhYz/urv/TATKMXguvi1xeJw/JLxVqewFrvRzyjEs9k2FqhSHqPJEGl0NGOWM Re4wU7f9iVjgaSiF9LeubxYH+Fnhkx0jD8PUOnPCaDqREybLDIf09FgrFZgMPcIb 1GTpfNhlLxkgwTDd/V8a1dcmEg77+25y16ksfoR1h4bb+Whf8VMTS1hJxvvZpAmO K7Pz00BpyTZMY2SGsccRCoSLxzwKLquT0/jmpbG4D/MACs70g39KRGMFT7w67+in ReIK4mvMmHYckTn1qfEk2n/Nq+e9EPecbn3DJg55qxBsnM6ojZjWJ98bw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedruddtuddgvdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdlfeehmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepgeffjeevgfevuddvjedtvddt ieejheduueelvddufedtgfefjedvkeevkeeivddvnecuffhomhgrihhnpehpohhsthhgrh gvshhqlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhl fhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 30 Oct 2023 20:40:12 -0400 (EDT) Date: Tue, 31 Oct 2023 09:40:08 +0900 From: Michael Paquier To: Robert Haas Cc: David Steele , Kyotaro Horiguchi , pgsql-hackers@lists.postgresql.org, zxwsbg12138@gmail.com, david.zhang@highgo.ca, Andres Freund Subject: Re: Requiring recovery.signal or standby.signal when recovering with a backup_label Message-ID: References: <20230928.125851.2051261991058034791.horikyota.ntt@gmail.com> <4f94351c-24e2-cf32-82d3-1e1bf89a0f5e@pgmasters.net> <0f25d737-64c8-4ef3-9873-f2d4f44b1431@pgmasters.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="2rutKFNomGYoFb8n" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --2rutKFNomGYoFb8n Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Oct 30, 2023 at 01:55:13PM -0400, Robert Haas wrote: > I would encourage some caution here. Thanks for chiming here. > In a vacuum, I'm in favor of this, and for the same reasons as you, > namely, that the huge pile of Booleans that we use to control recovery > is confusing, and it's difficult to make sure that all the code paths > are adequately tested, and I think some of the things that actually > work here are not documented. Yep, same feeling here. > But in practice, I think there is a possibility of something like this > backfiring very hard. Notice that the first two people who commented > on the thread saw the error and immediately removed backup_label even > though that's 100% wrong. It shows how utterly willing users are to > remove backup_label for any reason or no reason at all. If we convert > cases where things would have worked into cases where people nuke > backup_label and then it appears to work, we're going to be worse off > in the long run, no matter how crazy the idea of removing backup_label > may seem to us. As far as I know, there's one paragraph in the docs that implies this mode without giving an actual hint that this may be OK or not, so shrug: https://www.postgresql.org/docs/devel/continuous-archiving.html#BACKUP-TIPS "As with base backups, the easiest way to produce a standalone hot backup is to use the pg_basebackup tool. If you include the -X parameter when calling it, all the write-ahead log required to use the backup will be included in the backup automatically, and no special action is required to restore the backup." And a few lines down we imply to use restore_command, something that we check is set only if recovery.signal is set. See additionally validateRecoveryParameters(), where the comments imply that InArchiveRecovery would be set only when there's a restore command. As you're telling me, and I've considered that as an option as well, perhaps we should just consider the presence of a backup_label file with no .signal files as a synonym of crash recovery? In the recovery path, currently the essence of the problem is when we do InArchiveRecovery=true, but ArchiveRecoveryRequested=false, meaning that it should do archive recovery but we don't want it, and that does not really make sense. The rest of the code sort of implies that this is not a suported combination. So basically, my suggestion here, is to just replay WAL up to the end of what's in your local pg_wal/ and hope for the best, without TLI jumps, except that we'd do nothing. Doing a pg_basebackup -X stream followed by a restart would work fine with that, because all the WAL is here. A point of contention is if we'd better be stricter about satisfying backupEndPoint in such a case, but the redo code only wants to do something here when ArchiveRecoveryRequested is set (aka there's a .signal file set), and we would not want a TLI jump at the end of recovery, so I don't see an argument with caring about backupEndPoint in this case. At the end, I'm OK as long as ArchiveRecoveryRequested=false InArchiveRecovery=true does not exist anymore, because it's much easier to get what's going on with the redo path, IMHO. (I have a patch at hand to show the idea, will post it with a reply to Andres' message.) > Also, Andres just recently mentioned to me that he uses this procedure > of starting a server with a backup_label but no recovery.signal or > standby.signal file regularly, and thinks other people do too. I was > surprised, since I've never done that, except maybe when I was a noob > and didn't have a clue. But Andres is far from a noob. At this stage, that's basically at your own risk, as the code thinks it's OK to force what's basically archive-recovery-without-being-it. So it basically works, but it can also easily backfire, as well.. -- Michael --2rutKFNomGYoFb8n Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmVATOgACgkQnvQgOdby QH09uA//Wznit6hqh5+W/Ts/6cL1zFzD7gmY2jwfNI06tXGbEjjoDF3XGyF+5PVv OC5vhK3eWVDEqYggch34Wk72reyhsr0g4Pm/HuENOzHHZABZrq3H26znqMC3vk9+ wwgAZbVZAUpU+bXMDORIT5lMfI7eL0LiT5UcxEOGBjXRxFrJKUJnZt09oq3iDbi0 g6R6+k1twf0mMzaBUWOsRq7hPFoUGCUyn60E8u0+YpQ/4MlcS740BxvaRvZL9Wzr cxXkGwr+Zl0EF/Mz//1IybcOiHHRVeRAIXRycQ6EKkFFsZvt2OKW3FfO1P5agSRf AwxtN5is2lL4pcvpQ5zWTaDOjScO+ijX85CjBkBKyIgoc9c8Nsalll7dZyupYe92 Lvy/umY6I1iDeCS22+QVf87r5E75uKY3wGML9uVEVhyklRpkKwGKo6sp/2fX21yW ALat/KXdENCRviVWhvOLxy01SCbKupn+n00jndfwqmH+omBuR6a6IWaEPYRGDCUq ryKUxlkIRp+CPwyhtd2YUc/dabD4Puvn98nGQGFWMt0KlMJTJUzPPgUcJE/oP0pT jJz++eUrI0u/tT+m/PJvFZqgC+GKR7vRmZsHNMaQ+1vt9GPTFzuwrZbzL+7lWp7A iadUbzf+gw14iRdYsV3ys9d+V0YiK6lA7NHgjwF+Is/zqZvfJOQ= =bCh6 -----END PGP SIGNATURE----- --2rutKFNomGYoFb8n--