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 1qvuq6-008V7w-AM for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Oct 2023 07:31:35 +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 1qvuq4-00E0ix-Tr for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Oct 2023 07:31:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qvuq3-00E0io-Ft for pgsql-hackers@lists.postgresql.org; Thu, 26 Oct 2023 07:31:32 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qvuq0-002Mr7-68 for pgsql-hackers@postgresql.org; Thu, 26 Oct 2023 07:31:30 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 5ED575C01BE; Thu, 26 Oct 2023 03:31:26 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 26 Oct 2023 03:31:26 -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=1698305486; x=1698391886; bh=Hn 6EABUV6r3EcDSmwJ97M4UVnRDEfOdoVBEUP0v4xFk=; b=DNLg0msWpTZsgUF13g 0OgDApva5bUNRu4SfriQQg+Bxzeis9SR80G/+KPYR75YqWpSF7kraTGGAiPdT1Ko yW6I9uE9Du5raZ5Pb4Yp2oh4xQY2dYuEKW3NSViXL0jS/uSMSvUyvOvZHflw0Z5f dR7H2TA9zp9Id4QZux6CP77X13EqfWMOpChN4kOKvHjrWgcmd8x7c1rXO/7vwg6Z Uf0qIve7BemOaIK3HJ20J0o6SseSgh6+0DipKtRZChG+MhA75xJUbSdQsDlYNG7j 9AqcA1KG2fteABKkZya1zzbo/5Aw9R36QcJOag8CCWxnbb6sIfUOFPbBnljcoq5z OVBg== 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=1698305486; x=1698391886; bh=Hn6EABUV6r3Ec DSmwJ97M4UVnRDEfOdoVBEUP0v4xFk=; b=ImVpqcUFlViqMThxGQ8pVgCKYI/OU GCe6VKWlLca8BmExv/7byho+fiqH+OX+WiwHvmE/uho4B+YsiK1aehXaJdyox4T9 cHKb8BTAszNS6hduU1ewE3py4CEhVh2uKwBGcVtajV5m4v6RSRqws8To27DNKX/V GxBY8Vu4zKE2r87PK7EhQJjIxul75c8owbju3u6Uypjo1X+PUpcVPKUvVceh37Ai rnC+dbV1K8pZxutItZ5XtMb1E6E1t/f8qYlk8uYVqttbZDx35JcgLqTsLmontqNF F+Ot34wedbBumiuIgBppXD5GhXKEQ7CsWSQnm223Nuo7fbml5Wc9Zbf/w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrledugdduudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeg geegfffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih ii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 26 Oct 2023 03:31:23 -0400 (EDT) Date: Thu, 26 Oct 2023 16:31:19 +0900 From: Michael Paquier To: Jeff Davis Cc: Alexander Lakhin , Robert Haas , Heikki Linnakangas , pgsql-hackers@postgresql.org Subject: Re: Is this a problem in GenericXLogFinish()? Message-ID: References: <4b2dfe9c67713413a06be761f677bc34222afcb4.camel@j-davis.com> <23d87b531fab74e69fd753791a7e5047f17da9ab.camel@j-davis.com> <8a1c93b33b6e0aac92b771339cce520eac0adf96.camel@j-davis.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="yhiQ2EQ1CG8zFss4" Content-Disposition: inline In-Reply-To: <8a1c93b33b6e0aac92b771339cce520eac0adf96.camel@j-davis.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --yhiQ2EQ1CG8zFss4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 25, 2023 at 10:06:23PM -0700, Jeff Davis wrote: > Thank you for the report! I was able to reproduce and observe that the > buffer is not marked dirty. >=20 > The call (hashovfl.c:671): >=20 > XLogRegisterBuffer(1, wbuf, REGBUF_STANDARD) >=20 > is followed unconditionally by: >=20 > PageSetLSN(BufferGetPage(wbuf), recptr) >=20 > so if the Assert were not there, it would be setting the LSN on a page > that's not marked dirty. Therefore I think this is a bug, or at least > an interesting/unexpected case. >=20 > Perhaps the registration and the PageSetLSN don't need to happen when > nitups=3D=3D0? Hmm. Looking at hash_xlog_squeeze_page(), it looks like wbuf is expected to always be registered. So, you're right here: it should be OK to be less aggressive with setting the page LSN on wbuf if ntups is 0, but there's more to it? For example, it is possible that bucketbuf, prevbuf and wbuf refer to the same buffer, causing is_prim_bucket_same_wrt and is_prev_bucket_same_wrt to be both true.=20 Particularly, if nextbuf and wbuf are the same buffers, we finish by registering twice the same buffer with two different IDs to perform the tuple insertion and the opaque area updates in two steps. And that's.. Err.. not really necessary? I mean, as far as I read this code you could just reuse the buffer registered at ID 1 and update its opaque area if is_prim_bucket_same_wrt is true? -- Michael --yhiQ2EQ1CG8zFss4 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmU6FccACgkQnvQgOdby QH2nFQ/9EwMKon984xCilE6EPgJeYa4OqY+PqcVWkdU4UO9hTOSHi3dQNOQxr0EY 4wffDOzpALaFbd9hxEaAdezRF6FVgQCjc+of28wab/uoeTwdCRkEZHGqa5bKaxVB Dz1/phMWJgQL2HRiFTcTuopY+HCQo5P6U6GzsWQUYXEU37KW5Vcmqo+H+hjM+0w1 nRnnxjBX03R1demirKLOVJHIuX34SfgIz+ot7421jFjqnM9dBym+7oZ2gPCjl69z amLIdHu4ycoAmPuY/chEMnGBOm8N9/OtyD+HeZx2ftZeamfvA+exQZZ8KMIOnKk8 ASRdBe6zZ8TAM7y7U+/9d1BESbxA7IJ6VTcv3tVitps3RLubKT1DW5u8Jn1v/bOm STl8zKMiZXMxiyHePifIrXXpYPm+gHvO+mNN71tutcuL5UImLWdCr07QaNUVb/VS nyiTv8j/+6fo5T+ClBdPKB+wXmWCtk+4tv9D9zMdgAjWdVX629aVEplhbsqsDEDg 2O8mN1oqyWC4ba8RwWXM9bhdJHPP5kQqEZ1vM1fv46LGDff7m67N11zFulu//zSM 8bri11eOXT9d6SvG4Ug3Xhc7/W8gYw2KTKmMM9nWk22P/CwZ9F8O/N18CUjkQCZd R9uR9zk+4OQZE7K0+nDgFqaIUJs8MYHwgKX5cb7+YAkyDkNfPNw= =RQvt -----END PGP SIGNATURE----- --yhiQ2EQ1CG8zFss4--