Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1njxyJ-0002fI-Ku for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Apr 2022 06:49:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1njxyI-000759-Gd for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Apr 2022 06:49:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1njxyI-00074r-5t for pgsql-hackers@lists.postgresql.org; Thu, 28 Apr 2022 06:49:50 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1njxyF-0002V7-Ug for pgsql-hackers@lists.postgresql.org; Thu, 28 Apr 2022 06:49:49 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id DD2035C00D8; Thu, 28 Apr 2022 02:49:46 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 28 Apr 2022 02:49:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc: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=fm1; t=1651128586; x=1651214986; bh=rtuJy1myNv 0NA+aE0mRnV/gBmBKLNyOnvKIxdKVpkfs=; b=irEPYgh3WyN6U56YObwbuaQ6vl oZVwgidpoZOsSJsDJzwDCv2GReQzLplSVvB/8FUSAN++bCalHNKbtBW4A7s5s4aJ 9Dx7oQNs6PP9PSwXq20dwzuNRJTygHeze4ggBeLD6nR1dg5uePhveZiUEbRgy5jz NlgvkwHiE9jESNibDSas0bkfUyDcKzrWyGHoGCQ51Ze2rCWjDEhdvYfnbB6UXZUE c8poxgKJOxEuyYGfgFS2FHuqxF6eU9Qeynj+ou19r51RiDUGc9/jhbeBzEoau72M cfHXAPFZMHZkay4atdkEh/Tq/M6toSlHkvuSvmZU8gVZt9ngcVRmk7Fipf/A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date: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=fm1; t=1651128586; x= 1651214986; bh=rtuJy1myNv0NA+aE0mRnV/gBmBKLNyOnvKIxdKVpkfs=; b=K uZEXpX5ZbahLYH7oPXVK1obmCV4EdexF6+HEKdiqJYLGXQ/sd/20Qku0OyrEO2cA HTeC+GNqQSbmHlyh53gFOikVClBVhwxdW9j8hCfINUZel5cArypxR5pmx95MIBrm 4atEpg2KLCfgRxRxfpGKy7prlxIJavZXTHcWFakHU7lgPOVx4xRBH/PyRNHf7mm4 hZJnGyYu0FsmQDmZbSpmhuMSYDpkVbLcLhlS6Q0f4TKKBKIlY/85drx8krZMEHUB 7K/W9Kb3TqJmj81GclxxMDuhQZ76A39DmQtMCcGXRv1qyZ08uDy7O/xI5dUNWThT rwnUbxsu0FmHhCkL8dGVA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudeigdduuddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdljedtmdenucfjughrpeffhf fvvefukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghq uhhivghruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvg hrnhepteelieefudffhffhtdetleeggeegfffhkeeuveetiefgudduvedutefggeeivdej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitg hhrggvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 28 Apr 2022 02:49:45 -0400 (EDT) Date: Thu, 28 Apr 2022 15:49:42 +0900 From: Michael Paquier To: Kyotaro Horiguchi Cc: nathandbossart@gmail.com, pgsql-hackers@lists.postgresql.org, masao.fujii@oss.nttdata.com Subject: Re: Possible corruption by CreateRestartPoint at promotion Message-ID: References: <20220427180945.GA3222843@nathanxps13> <20220428.114357.476887320744154615.horikyota.ntt@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="VKPg5Q1jTsQIbsR5" Content-Disposition: inline In-Reply-To: <20220428.114357.476887320744154615.horikyota.ntt@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --VKPg5Q1jTsQIbsR5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 28, 2022 at 11:43:57AM +0900, Kyotaro Horiguchi wrote: > At Thu, 28 Apr 2022 09:12:13 +0900, Michael Paquier = wrote in=20 >> On Wed, Apr 27, 2022 at 11:09:45AM -0700, Nathan Bossart wrote: >>> On Wed, Apr 27, 2022 at 02:16:01PM +0900, Michael Paquier wrote: >>>> - if (ControlFile->state =3D=3D DB_IN_ARCHIVE_RECOVERY && >>>> - ControlFile->checkPointCopy.redo < lastCheckPoint.redo) >>>> - { >>>> 7ff23c6 has removed the last call to CreateCheckpoint() outside the >>>> checkpointer, meaning that there is one less concurrent race to worry >>>> about, but I have to admit that this change, to update the control >>>> file's checkPoint and checkPointCopy even if we don't check after >>>> ControlFile->checkPointCopy.redo < lastCheckPoint.redo would make the >>>> code less robust in ~14. So I am questioning whether a backpatch >>>> is actually worth the risk here. >>>=20 >>> IMO we should still check this before updating ControlFile to be safe. >>=20 >> Sure. Fine by me to play it safe. >=20 > Why do we consider concurrent check/restart points here while we don't > consider the same for ControlFile->checkPointCopy? I am not sure what you mean here. FWIW, I am translating the suggestion of Nathan to split the existing check in CreateRestartPoint() that we are discussing here into two if blocks, instead of just one: - Move the update of checkPoint and checkPointCopy into its own if block, controlled only by the check on (ControlFile->checkPointCopy.redo < lastCheckPoint.redo) - Keep the code updating minRecoveryPoint and minRecoveryPointTLI mostly as-is, but just do the update when the control file state is DB_IN_ARCHIVE_RECOVERY. Of course we need to keep the check on (minRecoveryPoint < lastCheckPointEndPtr). v5 is mostly doing that. -- Michael --VKPg5Q1jTsQIbsR5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmJqOQYACgkQnvQgOdby QH37Ug//R16pNCF36STNFldlJTU0N5Xyqk3BDCUMfLDQF+ahCwhmS9TmQ9SaL1WF MTdkOjTEog25mRzDjQkpO8ggVoeyGtkws3kj04LLiPa+tWPuN1rNjoZzvAiCqVKX PiPwd2th7oTAm+/3VKOYWMeWwDVecMFaCVVQXxZQThOsSR39ZGBxbFwNk9G9Ox/0 4kZ4oeaGkffax4Ikno/yEEExh5QL4L9jsZf3DmB98FfVOc/0VIHYxPp+QRrnV/gH JSfU3uZSrpmeGZhq02TC16VG7bm4fOb4teRxWXjBDIfYEdDkZc9Yhm9sTmAYD1q/ sMCPBTfxpkfY72B3pPTyepaLsKewdJ0k2iSQc9ZWfQAMt/StLCByXoagALNce43t XD5Ka2EZuQv2h16IK9W8b1HCnUiJn6qpQZRXQJzwRoL7M/4SS0LsVQdMQp/qWkyk fGL5Qoa03jzzZRzHXWi6FYX1yvQQwHamnabPtyyZRgpWvvhebBhS8PT0E8SU6zFS TF9nnDTszNasjUCWEYCkv+NBDdp2Y+sK5hQSRf14dY6q7hygKOov149Bs5iSR6ec 5eFnU/AhbkwlQX7PTTPpL6XRPsXiVwE9HVW3MbfCsrUkZ7rfrb7AMeVx07aNorhi NOB40p7WjZpA3rH8BMZpTA/2JzOpaF2QLTFi0Jc00aRB6BwAJnw= =NAR9 -----END PGP SIGNATURE----- --VKPg5Q1jTsQIbsR5--