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 1ubEL2-00FKla-No for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Jul 2025 08:15:05 +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 1ubEL0-004ocn-Mm for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Jul 2025 08:15:03 +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 1ubEL0-004oce-20 for pgsql-hackers@lists.postgresql.org; Mon, 14 Jul 2025 08:15:03 +0000 Received: from fout-a7-smtp.messagingengine.com ([103.168.172.150]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ubEKy-007TOH-09 for pgsql-hackers@postgresql.org; Mon, 14 Jul 2025 08:15:02 +0000 Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id B342FEC056A; Mon, 14 Jul 2025 04:14:57 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Mon, 14 Jul 2025 04:14:57 -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:subject :subject:to:to; s=fm2; t=1752480897; x=1752567297; bh=TpLJ7AFXmP sTs/ZywPWbEcZkddX27VjRR/MOU725vuI=; b=iqGh5753z9tfQPaBPo8ULTNboh hwWwQ50LYyUt/RWZT4yMafyWEzeIE0k32vGKy/T8s3l5u+7Mybh152SCa6yJ5E+q WrMR/7aorpMzYUyDo56u+R/0GDX8kYpj8ewjs2BSjiZBDeHfbZHf+kCIaM1hoRpz u1fls/Skxj5OrIsYRWPNO0lI7jq9DzeOErWLFltjSEDYFkfAgOb6dP0DENPIA2/Y utiQ5VB/kQnjRQw3y8SUkPlWKsUJByoEJU2zxw0PetlRJSSu6JQOcyTOcPH9lnVu 2Vq4FTbXd4LoD2JwBe7fat6s7ywsEVN03N8ejlWGwSoZ9AVrQFaa59VQJI5w== 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:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1752480897; x=1752567297; bh=TpLJ7AFXmPsTs/ZywPWbEcZkddX27VjRR/M OU725vuI=; b=J/dTleEJQkV0s2m7RSdo0+Ze0dZtZwwgu0OT7D3aijGXGBYLKd/ vcalj/MUDKEQPMSYoP7A1wuw6mVqTmkbE5NOZ+iuvWpxDFareVKWxslXA/EI1slg 3OYjNC/iM8D3kEj49BjDBxWMDjnfX510arUp7NQSY6Y4gfHytBWS4rLuUe8bMzpH /Gl9zND4hWrUCp5g2ATHESOxen7LxPkIi1yBRtDs+595t5jmT3iBkZ5QPQ5clgUK WI2X0rP5p9xX+CIHlEv87S7E3hX84w4VTJn8W2nv4DU1vibohFtvPWKbGV/ZdNtW LG89dNdjjj2enn9PWvXIPbtCV/SWjfTqcZg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdehudeghecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeggeff hfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhn sggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehmvghngh hjuhgrnhdrtghmjhesrghlihgsrggsrgdqihhntgdrtghomhdprhgtphhtthhopehpghhs qhhlqdhhrggtkhgvrhhssehpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 14 Jul 2025 04:14:56 -0400 (EDT) Date: Mon, 14 Jul 2025 17:14:43 +0900 From: Michael Paquier To: "CAI, Mengjuan" Cc: pgsql-hackers Subject: Re: The same 2PC data maybe recovered twice Message-ID: References: <27cf1fe2-e8f9-4fca-a828-aa3ad3397acd.mengjuan.cmj@alibaba-inc.com> <02595127-20e2-454e-a4fe-0a7e376a1917.mengjuan.cmj@alibaba-inc.com> <5179d749-cae2-4eb6-8dbc-c97e827d7ce5.mengjuan.cmj@alibaba-inc.com> <012f3c16-1641-48be-b0b7-fbf194dc39e9.mengjuan.cmj@alibaba-inc.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="yYfkxjSty/MKuAiK" Content-Disposition: inline In-Reply-To: <012f3c16-1641-48be-b0b7-fbf194dc39e9.mengjuan.cmj@alibaba-inc.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --yYfkxjSty/MKuAiK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 14, 2025 at 02:46:25PM +0800, CAI, Mengjuan wrote: > Thank you for your reply. I reviewed the thread you mentioned, and > it seems that the issue needing to be fixed is not the same as the > one I previously raised. > I am considering whether the 2PC file check logic in > PrepareRedoAdd() can be modified. Currently, each time a > XLOG_XACT_PREPARE WAL entry is replayed, it checks for the > corresponding 2PC file using access(). Each access operation creates > a dentry in the OS, and in most cases, the file being accessed does > not exist. When there are many 2PC transactions, this logic may lead > to an increase in OS slab memory. In worse scenarios, it could cause > the reference count of the parent directory's dentry to overflow, > potentially leading to an OS crash. Typically, when accessing > existing files, the disk will fill up before the dentry reference > count overflows.=20 > Therefore, I would like to propose a modification. Attached is my > patch for your review, and I hope you can take a look at it. @@ -2520,8 +2520,16 @@ PrepareRedoAdd(FullTransactionId fxid, char *buf, [...] - if (!XLogRecPtrIsInvalid(start_lsn)) + if (!XLogRecPtrIsInvalid(start_lsn) && !reachedConsistency) Actually, what you are doing is incorrect because we could miss some ERRORs for example if a base backup was incorrect if come files were present in pg_twophase? It's not really true that what you are changing here has no interaction with the beginning of recovery, the other thread is about the fact that reading the 2PC files from disk when !reachedConsistency is a bad concept that we should avoid, impacting the assumption the code path you are changing here relies on. At the end, it may be possible that we're able to remove this check entirely.. -- Michael --yYfkxjSty/MKuAiK Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmh0vHMACgkQnvQgOdby QH1YZw//aUD3MwpimIsJ/A7glG8MVjNIcXc9Tij4gpns0vcSK00Md5ekCSx4fEp6 pZBxgivnlV7ZV7DtMunPCiWj+OENr6+eNZ3C7JZKDeZimf0GzwD5NC5tlssQDLlW w20hGnjmVHrMPMyTWpQ0D7y9dZY9s/+dje2hdItf1igBdUKvuLZsQETJ3G8+TVkz nG6lw6sG8CuctBdz9sCDxw/bvS7HkusYCvVY4UyKVam2YkiDrZNaNfLa0o+offFc EN/cTUKKHVyVKuDDriEwrhfwJ7H0/1n2bxpbQxiloseu5YkdQE3x2KPIx3vNJAnh 1EDNAM02q9BnAcT70iHsQQgXzo55mlUfLN2NwJpVmljkg2pV5aGh+2B6S30ZTFOV sPWouEmNrWfAKEYTeNh92qW1kJhRZLADQbiSGVmopKlRchMxienrZfOXhYcpPtSi xmC22kXdqdsZ645uhYH8Nz/iQb9lPRwfCTxM90HtpWci3LLOxJNGrwq0tpspnRDs MtnR+0EqSio3NQ7lQipvxEhEpSFbVFGIUaoz9U8HEp7cAzYg425W0VqcbsusFdoM Hw12fN0IyI4VbqyMxk0NzXqUJpInOdxyjCOTCa+RWF7gxemgA8+oy6X45FfRqsMd 0ApYocv6JolwpJzbZtiPbSFABmF02B7jrMs/W9Usfo5p/TGpDlw= =BwRE -----END PGP SIGNATURE----- --yYfkxjSty/MKuAiK--