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 1qrCc2-0035rQ-20 for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Oct 2023 07:29:34 +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 1qrCbz-00FNlS-0d for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Oct 2023 07:29:31 +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 1qrCbx-00FNlJ-FU for pgsql-hackers@lists.postgresql.org; Fri, 13 Oct 2023 07:29:31 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qrCbq-000J9P-9p for pgsql-hackers@postgresql.org; Fri, 13 Oct 2023 07:29:28 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id C532C5C032D; Fri, 13 Oct 2023 03:29:20 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 13 Oct 2023 03:29:20 -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=fm2; t=1697182160; x=1697268560; bh=PV VMdkC2N5Zldb9ifovqurnTwpAclHNVa8/7VSstaHI=; b=P4BqSIqmjjEsNrTVed ZhgD2mGqpeaYUfecB+3noc6440AbgB0w+q7csIhi2XZ5t/AZ9fGIsTIR03O9XrAo ZcNDMusCRkbWamWNxbCBoxI2WW/D59ZwS2kE4spXdpkJC7D4sKKHl3f0EPWl4Smz LORRf6SDMPTEBFgYfo7xpSFlrlzcZ/8V6PCG+bdJxfK7qr+dTKYW89R+o3P72ssL q2/Q608zt0gf0DVSjCmR6H82jg6ZdG2Jzvf+BlsKqPVPTs47pIynACN7bJaOho9L 79Y8Fq318x8LpSrJXVNhMZWV+c9ce2MvLpq5sENIpQL2Co52rk3zagPFBp1yeLHn NQmA== 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=fm2; t=1697182160; x=1697268560; bh=PVVMdkC2N5Zld b9ifovqurnTwpAclHNVa8/7VSstaHI=; b=RQ7O0vrZj4rwAx+Zs/+7NyzyE5VuY eoISU2BJ/6XmXS5TzJvyFXodfGi5+lQxkWmH3JrHXT9rPs4Ef/clfscxfClOB64c O0uGJ6vJFHIBovrHZ4f1bSahO0EBazeu9OTEMGIXgw0QViDcLg5ptyuRC/ebd2SG riSywxdUWZAMyCxmz8ykj6ar5yBOVnIDrEJTsmriuPwyI2RgsXQzxg9HWj3t3fLZ IriAGSV1Ep5ziOK9PFtM/Jemj++cRAATgQ+/SDH8Tldjl7BuXY6g6Bqh0Xuh7Wf8 Oi64FUyiOk0+mxNSeMLlQbvNybcPlE9GK7lfXM/53H/zJcaMhq1PbDiSA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedriedugdduudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeg geegfffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih ii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 13 Oct 2023 03:29:17 -0400 (EDT) Date: Fri, 13 Oct 2023 16:29:12 +0900 From: Michael Paquier To: Robert Haas Cc: Andres Freund , Dilip Kumar , Heikki Linnakangas , pgsql-hackers Subject: Re: New WAL record to detect the checkpoint redo location Message-ID: References: <20230714151626.rhgae7taigk2xrq7@awork3.anarazel.de> <20231005183400.n5myso7vu6crd656@alap3.anarazel.de> <20231009204702.cy3ilp6wgh7a5qms@awork3.anarazel.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="vOrhidVr5q2OttQm" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --vOrhidVr5q2OttQm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Oct 10, 2023 at 02:43:34PM -0400, Robert Haas wrote: > Here's a new patch set. I think I've incorporated the performance > fixes that you've suggested so far into this version. I also adjusted > a couple of other things: Now looking at 0002, where you should be careful about the code indentation or koel will complain. > - After further study of a point previously raised by Amit, I adjusted > CreateCheckPoint slightly to call WALInsertLockAcquireExclusive > significantly later than before. I think that there's no real reason > to do it so early and that the current coding is probably just a > historical leftover, but it would be good to have some review here. This makes the new code call LocalSetXLogInsertAllowed() and what we set for checkPoint.PrevTimeLineID after taking the insertion locks, which should be OK. > - I added a cross-check that when starting redo from a checkpoint > whose redo pointer points to an earlier LSN that the checkpoint > itself, the record we read from that LSN must an XLOG_CHECKPOINT_REDO > record. I've mentioned as well a test in pg_walinspect after one of the checkpoints generated there, but what you do here is enough for the online case. + /* + * XLogInsertRecord will have updated RedoRecPtr, but we need to copy + * that into the record that will be inserted when the checkpoint is + * complete. + */ + checkPoint.redo = RedoRecPtr; For online checkpoints, a very important point is that XLogCtl->Insert.RedoRecPtr is also updated in XLogInsertRecord(). Perhaps that's worth an addition? I was a bit confused first that we do the following for shutdown checkpoints: RedoRecPtr = XLogCtl->Insert.RedoRecPtr = checkPoint.redo; Then repeat this pattern for non-shutdown checkpoints a few lines down without touching the copy of the redo LSN in XLogCtl->Insert, because of course we don't hold the WAL insert locks in an exclusive fashion here: checkPoint.redo = RedoRecPtr; My point is that this is not only about RedoRecPtr, but also about XLogCtl->Insert.RedoRecPtr here. The comment in ReserveXLogSwitch() says that. -- Michael --vOrhidVr5q2OttQm Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmUo8cgACgkQnvQgOdby QH1kYA//cKs/BcQO1D6LvLzZMsBxK6fxZGHdNVtvNQN5Mz5cWHizYb96wyGzxM93 eARciHwiUAIS+Xi4GXCJiQ4+mDO0oenpuwfdAo+KWVuN8vTxfu7oH8RygSV1cuWB HuVeSw2olzeVlFWVuS3WW4IDMQpwCkez44sZ25wJ82Xvz8P3q/NlIdvib7+9Dv8S cCkDCwaUQT8PoUPtX96Z0SAwj7H+ZOoA6cBxG1AUQ2+vUyqu2GX2pP6Wixoscc92 exlv2KA+F0k/HHKCg1Lpn5MTubmKwB85qD7Vodc9vtCUVIcsmnxhhfNvDnCFg3yb fVGqQJZHyQ4Xg46CN9H5HvUXluYcwKJwlBcgtDpSDMIENI9bhu7Qg9kijsWM526V MGVk4rRMKKxxQvoRsO/RRiRhxsohc7iai56PTbfXqTaUxUGnEBgzox7Sics/vgnN Ovjp5tD94sCjIf7wU+jsAx+HGIUyXx0eRw2IueyJfnMIvNBVWPl2KikONr2iaUly LfWbUxMc6vyQPlEGU0wI+u0hAvrZjK3OYvN8ILhHi6XDv571q8uxaA0VPTiVJhDM Y0LiD4EVWEgPHTtTGPxJLfa2utLJEDGoW4PZ66fGSDT9I/oZJuTB06fz4Yyns6X6 I/x9K5jDgJ5LJLj94lLk81CwivO81ABFIIu2OTdwrBnmjT2Ug00= =THPH -----END PGP SIGNATURE----- --vOrhidVr5q2OttQm--