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 1uZPLE-0035tX-PS for pgsql-bugs@arkaria.postgresql.org; Wed, 09 Jul 2025 07:35:44 +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 1uZPLB-00EB34-Mi for pgsql-bugs@arkaria.postgresql.org; Wed, 09 Jul 2025 07:35:42 +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 1uZPLB-00EB2u-DS for pgsql-bugs@lists.postgresql.org; Wed, 09 Jul 2025 07:35:42 +0000 Received: from fhigh-a6-smtp.messagingengine.com ([103.168.172.157]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1uZPLA-006M1j-19 for pgsql-bugs@lists.postgresql.org; Wed, 09 Jul 2025 07:35:41 +0000 Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id 69C7014002D9; Wed, 9 Jul 2025 03:35:39 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Wed, 09 Jul 2025 03:35:39 -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=1752046539; x=1752132939; bh=p15+EPJZFR wbuxf087BXJUdHeArF304WHsuOGMUDzDI=; b=dM5UAI1cJHG5R0KGGlWrGXmOey 7FZcWAb9BBxc/prbk06ls4clTUSpz+wFKB361opIYj+Y/vPo8PawXrLStOT7PD9c s3iDLZ5kxfYF0OcNOIeEQug1sDm9ENRDMANwpYfyZCGscwscvCavaqphVwpx2x8Q /D5Vzc1teQSmD5SxlXxEkaF9uwtty6sAYItzqu5a/t71ygOpmBKJn6ZG5Li5nbYE Y9Q38419oVFRsGFAF7A4TWrlI81lPIwJEAmb6qe2+0/JgVNV6z5hSebtkx1TEbAD eyy/Rt+vipS42j9TOoRug5BM+o6l5oYyGvRzJd58tgH7ElHuKw/iN3SeYvhQ== 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= 1752046539; x=1752132939; bh=p15+EPJZFRwbuxf087BXJUdHeArF304WHsu OGMUDzDI=; b=VQS4hi3V38msJDsjsep2t21T47QgICUBczpMlYrKuW+NPc227N4 BjVBCY/FSih9TYRu6sNZZE9y19ZkOu5KZo56MjX/x7W07TFN6VW1IzcIly/aki3P Px7nX3TJXRFqGYyT23JvsWaQ6qwQuGZDIxPfyxDYZ85OzDqxMNqozA0f7eDqxik8 3eus/OALpOS/2dTLvVpTAR/Tw/sors0CSrAaF51Tzkwn5mhqJ+SXIEPgqMNc0mGf cuaER+tQSgilvYxhgy1VtkuhT2PzJwgNZyAvkAGQPM9vT86VFe3K/dPFTh6mBFIr +pp678uHwoO7LEM1qmg71Mpq+fK/ld9t/HA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdefieelkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecufghrlhcuvffnffculdefhedmnecujfgurhepfffhvfevuf fkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgv rhcuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpe egffejvefgveduvdejtddvtdeijeehudeuledvudeftdfgfeejvdekveekiedvvdenucff ohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih iidpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepmh gvnhhgjhhurghnrdgtmhhjsegrlhhisggrsggrqdhinhgtrdgtohhmpdhrtghpthhtohep phhgshhqlhdqsghughhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 9 Jul 2025 03:35:36 -0400 (EDT) Date: Wed, 9 Jul 2025 16:35:23 +0900 From: Michael Paquier To: "suyu.cmj" Cc: pgsql-bugs Subject: Re: The same 2PC data maybe recovered twice Message-ID: References: <0706bec1-80ae-4f99-8cf8-c89734978770.mengjuan.cmj@alibaba-inc.com> <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> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="+3RCvOUg+hH93+qO" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --+3RCvOUg+hH93+qO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 09, 2025 at 01:51:03PM +0800, suyu.cmj wrote: > Currently, since restoreTwoPhaseData() is the only function that > restores 2PC transactions from disk before the recovery starts, > after reaching a consistent state, the 2PC transactions are only > added from the WAL. Under normal circumstances, there should not be > any corresponding 2PC files on the storage at that point. Therefore, > I prefer to perform the file access checks only when the server has > not yet reached a consistent state. Once consistency has been > reached, if a duplicate 2PC transaction is added, it will directly > result in an error in the subsequent replay logic.=20 There is a bit more going on in this code that needs to be fixed. Please see the following thread, that also relates to the state of the 2PC recovery code when we read them from disk at the beginning of recovery, with the bottom part being the most relevant: https://www.postgresql.org/message-id/Z5sd5O9JO7NYNK-C%40paquier.xyz -- Michael --+3RCvOUg+hH93+qO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmhuG7sACgkQnvQgOdby QH0E2Q//cDMdt+wDFriqnkvZsIP6pC3JwKt4gsod0Q4kMFQsUL3DK9f0Ii9Igvsa vMPV3tEq04LKbistPUXX5q29qoMmUYaFOW98ahPK0vgHKRd8r/+MXrLJUq2Pk675 bxtZLCLZzOmUA7VVcYHZ/lRlQrtMjIVbTdLP00+Ec1KbXpulhVgym1jcVSmxKaqF UrYZvy+MAtdUaF1/oHaIUacSn/sU+bUSfx7XfIk+R+601CjEt4ns8glhVu6DQ7Bs Qd1tYFFv3pLUe6bWjMBK7ARec63fcXdnornYCxpyEEyWY8xYaiH28NDEIRLm3WvJ m8fwQlShFHPbKqNdtyWQEesv3wKSmAA3NBvzJ6Mf63z38S53+k4eoizQMeNgimi6 qTZqL2o/47285qrjbjAY3T8hdrP9EYNBR/LA4NjB005eas6CeRUkZWILN+HCnHKk aNEZOv7Mwl3GZhrLz7o4L5boJsZD6M7xZ654yO2lL0jrKRTbvGQsFjnd7P/KwuXm UEPpbtdHEDGyClBWnvBwrVO6gyceiMSKmyB+kMNuY1Eucdw2Nx4+XvfRn97+x/rX lh5WmVW5WUPSYDfC5/L9mdFuu+IbM4tPLvQva7gq7m5Y2AWc9rwiNRzYEhPFhymZ yCKC9B3+Z2rfpKSiyASmEF6dFHMoOqMAjKi53rBhkdk0s/Q/BjA= =PGFR -----END PGP SIGNATURE----- --+3RCvOUg+hH93+qO--