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 1tQpWS-005S6g-On for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Dec 2024 15:11:37 +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 1tQpWP-002wHC-VJ for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Dec 2024 15:11:33 +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 1tQpWP-002wEA-LK for pgsql-hackers@lists.postgresql.org; Thu, 26 Dec 2024 15:11:33 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tQpWM-000fH6-0n for pgsql-hackers@postgresql.org; Thu, 26 Dec 2024 15:11:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1735225886; bh=iZ8zX1ArnlGTOysxOecvQMftSaVdTKm+FLEUlU6TndU=; h=From:In-Reply-To:References:Date:Cc:To:Message-ID:Subject: User-Agent:From; b=K3IeeL1WyAKaLXh1kbsA7Ura/Lm623QE5mwqKagXyl4SXNSePEcP23GUr2cuoLG8P Ziwt0MJlSFKp34G50zfNcK6ZRCHQugfXIBSdG1cghKWorW+EJpJaqHdDar9KwOO4Af ffPWbePzqZ62KZ0QXlGPuh23lRnmDfWA1s6Iau8loIo/pqc94wsuMm6WAqMNECAuos YqhxdiXSg7lvhnWdkcqNvAT+GtdOnbrCu302VEG+XfoJ8Y27CxBSCdvq+TcOLBZ7nd yLW7c36RXPqYN3TwUKVX2f9Ef/8YH7pBDW9ujj/YlClv3AM6YouJDkp5mLhbja1zNj 8QKey/eUDl93Q== Received: from sogo.postgrespro.ru (sogo.l.postgrespro.ru [192.168.2.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by mail.postgrespro.ru (Postfix/587) with ESMTPS id 03B2F5FFDD; Thu, 26 Dec 2024 18:11:25 +0300 (MSK) From: =?utf-8?q?=D0=94=D0=B0=D0=B2=D1=8B=D0=B4=D0=BE=D0=B2_=D0=92=D0=B8=D1=82=D0=B0=D0=BB=D0=B8=D0=B9?= In-Reply-To: Content-Type: text/plain; charset="utf-8" X-Forward: 46.39.228.239 References: <13b5b6-676c3080-4d-531db900@47931709> Date: Thu, 26 Dec 2024 18:11:25 +0300 Cc: "pgsql-hackers" To: "Michael Paquier" MIME-Version: 1.0 Message-ID: <152dda-676d7200-61-659acf0@102179597> Subject: =?utf-8?q?Re=3A?= An improvement of ProcessTwoPhaseBuffer logic User-Agent: SOGoMail 5.11.2 Content-Transfer-Encoding: quoted-printable X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2024/12/26 12:50:00 #26919000 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Michael, > Here are two patches to address both issues: Thank you for the preparing the patches and test simplification. My bad= , I overcompilcated it. I concerned about twophase file name generation. The function TwoPhaseF= ilePath() is pretty straitforward and unambiguous in 16 and earlier ver= sions. The logic of this function in 17+ seems to be more complex. I do= not understand it clearly. But, I guess, it will work incorrectly afte= r turning to a newer epoch, because the epoch is calculated from Transa= mVariables->nextXid, but not from problem xid. The same problem may hap= pen if we are in epoch 1 or greater. It will produce a wrong file name,= because the epoch will be obtained from the last xid, not from file na= me xid. In another words, the function AdjustToFullTransactionId assume= s that if xid > TransamVariables->nextXid, then the xid from the previo= us epoch. I may be not the case in our scenario. > I suspect that this can be still dangerous as-is while complicating t= he code with more possible paths for the removal of the 2PC files Agree, but we may pass file name into TwoPhaseFilePath if any, instead = of creation of two functions as in the patch. The cost - two new if con= ditions. Using file names is pretty safe. Once we read the file and ext= ract xid from its name, just pass this file name to TwoPhaseFilePath().= If not, try to generate it. Anyway, I do not insist on it, just try to= discuss. With best regards, Vitaly