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.98.2) (envelope-from ) id 1xL7Ac-00000001Jd9-3ND5 for pgsql-bugs@arkaria.postgresql.org; Sun, 25 Oct 2026 22:58:31 +0000 Received: from localhost ([127.0.0.1]:33156 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xL7Ac-00000001MFQ-1MQZ for pgsql-bugs@arkaria.postgresql.org; Sun, 25 Oct 2026 22:58:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:49092) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xL7Ac-00000001MFB-0Bl9 for pgsql-bugs@lists.postgresql.org; Sun, 25 Oct 2026 22:58:30 +0000 Received: from mail-vk1-xa36.google.com ([2607:f8b0:4864:20::a36]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xL7AZ-00000000xi4-3OYA for pgsql-bugs@lists.postgresql.org; Sun, 25 Oct 2026 22:58:29 +0000 Received: by mail-vk1-xa36.google.com with SMTP id 71dfb90a1353d-5c82b4d250eso133025e0c.0 for ; Sun, 25 Oct 2026 15:58:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792969105; x=1793573905; darn=lists.postgresql.org; h=content-type:mime-version:references:in-reply-to:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Tx12XWhoRAOQpZ9Tcy02ZV+tdgX26eOHldyewH2iAQg=; b=ozPlOi3NcjN8QTRVivUAdSGGgEd5bs4YvRJ1RcAiNIsbyM9Ci7QjKRqb5hGNxQWaQl HNlKrweHIzxc/su8SCPgbx4BdTh+RcPyVdjZPYdZi7ysfa+7I2jSBi4Wx48PW21xrFZ2 Dl9PiZfz8NajMBt3MqiqmMT/5ZIZ8qh2mou3vzRmNLHIRTM3sxOYjZcx/P+YPOwtY/ye 5os3UFg86LLtwRPJ6YWv9mdKghurA1uLvnSVVxhLQKviD/0uitwVMbyhsH1ex89KBZr+ G2Kwt2mNejZE1zh51LbdceplNfD4UhWUJTfH/T/BXFESjiwkK6/S7GenUVdNSEletQ3C o0fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792969105; x=1793573905; h=content-type:mime-version:references:in-reply-to:message-id:date :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Tx12XWhoRAOQpZ9Tcy02ZV+tdgX26eOHldyewH2iAQg=; b=k7AJp52txCbPBypX8a0+i3f/CrOKIvmZXlOusTAB/FBm1elxt2anWzocQ7YNcoq8Do lxIRQ52tt7OFMas8QkGuvgnlvbrYB+QBdt26JA+GbVgrRCA1STnb43Pdktb+CjwzbszT lPKZXcopXennEBLnRcbn7vIN6HDi0tUZIdVTcIp273jN5y9pa8pUNHgai70B8iHMeR8a BZdvpGk6IMYGzv1s4XDy5BaGxyTAAs/qZ3rRXHu16n1hf6dlglX5IYtUsa3OPHInafEj bkGJcCPkq0CzNzvDlSRjP2UT3jrPdBAzktZp7lONYoYSN1n22+IC4dNDXw68j9Miuk9a plsA== X-Forwarded-Encrypted: i=1; AKwUvBwUFUmh78EA0NKWA2llPPQcobh54xTHkdSbK7UfNql9XVhWDPI5YeA++8QLb0IguZ1wz5iNT+0a/WRo@lists.postgresql.org X-Gm-Message-State: AFq9FYIEFQ59MHEl8d+UYAlbnWhDefw+BD1W/KTFBCY1loJDCZHpg7Zc fWSed2nb5z7TxvM7jmYygjBaLaH6KbhJ8y7yr74F0+SinHEI8Dc9+4ws X-Gm-Gg: AYBFou3Fl8GL8Zovypfg0tF/LGhiB67HuFvGBiSkLc079Z9mDEBhJvSSvcxhAvbRALk kbrJDP+84VM8ukFyk1o0pHB5YXpy/SQCpdEjFaV/469o+vVyYrg4ALIUM1Yc2S95CZQXSWpHQzp CVSMIw9+cxOLBZU643SvTFmtkGZPTbK3Z5tFVaIdKM6kbaKelQkIGTr6ED/LX0FeqNgW1NTUk6R IR/cuODs8rU9BSnH1y5l8MWjkvlOcNf9CwCmDDnk4ffXmhnw+50yDORwfBqiDuzo3kzeSeUu3Ov Op51Sd9OAwKHhEERjNm2sH9w/iqOsEiuZ/j4JH+QtONyV8PjR3+DQBk5LLIWaXrhUdis9pP7iBN uitB9SpLuvh+aSuc77Eq3e1/1y/QJK6FvShhQobfj+WEWREVOt1qlVqOQCCtGL+UUFRDSkg3tAJ 9HT+tIK8SNOgkOeZbtICJ0hy2Bukytc7VTQGYXkNNjAwCDsEvr2mSrq4iYNbAgoN5xzZw1ZcTWb PALn7mP1AXzmY9ie3DIYYrm5GmHQvei68nwSO2CpuWIA43Y5k9vcaQtRR2cSxS00zXb3DfaZMUy NCAUODNtrRojLjEycxtHmP5KLy3IlSwXAMKihykew13dulFNsK3PRv0DL317SpjJsqEBVFSQnrE aakE1tFw= X-Received: by 2002:a05:6123:4201:20b0:5ea:b7b5:454 with SMTP id 71dfb90a1353d-5ec230af32bmr979051e0c.1.1792969105102; Sun, 25 Oct 2026 15:58:25 -0700 (PDT) Received: from 192.168.1.109 ([2803:3c90:cee:ea00:5c3c:7e70:29e3:7a55]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5ec234673ebsm6427617e0c.13.2026.10.25.15.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2026 15:58:23 -0700 (PDT) From: Manu To: Zhijie Hou Cc: Michael Paquier , shihao zhong , Takeshi Ideriha , Ayush Tiwari , alpkeles99@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19760: CLUSTER loses a row the transaction inserted and then updated in a rolled-back subtransaction Date: Sun, 25 Oct 2026 19:58:16 -0300 Message-ID: <179296909690.2912611.12132607274884942288@gmail.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3859942140528650571==" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --===============3859942140528650571== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi Zhijie, On Sun, Oct 25, 2026 at 4:31 PM Zhijie Hou wrote: > This doesn't look safe to me. Even if TransactionIdDidAbort() returns true,= the > xmax may not have been removed from PGPROC yet. So this change would create= the > risky case where the old tuple has been marked as XMAX_INVAL while the new > tuple's xmin is still considered in progress. You're right. On master dfd7ede529f with v2 and nocfbot-0001, your test fails in 3 of 3 runs once nocfbot-0002 is added ("failed to find parent tuple for heap-only tuple at (0,3)"), and passes in 4 of 4 without it. I took the order in RecordTransactionAbort() (clog first, proc array later) as the reason the clog alone was enough, but that order is what opens the window: until ProcArrayEndTransaction() runs, the new version of the tuple, whose xmin is that xmax, is still in progress, which is the race the note at the top of heapam_visibility.c is about. So the clog can only be a filter there. The attached diff replaces nocfbot-0002: it keeps TransactionIdDidAbort(xmax) first and then confirms with !TransactionIdIsInProgress(xmax) before setting the hint. It passes your test in 4 of 4 runs, shihao's spec, cases 1-3, 5 and 7-11 from measurements.txt, and make check, the isolation suite, injection_points and test_decoding. It keeps what made nocfbot-0002 cheap in subxact_updates.sql. There xmax is a released subtransaction that is still running, so it is not aborted in the clog and the proc array is never asked. One VACUUM makes the same SLRU accesses as with the old nocfbot-0002: 999937 clog and 999872 subtrans, against 999873 and 1999744 with nocfbot-0001 alone. When xmax did abort, it pays both lookups until the hint is set. I have not re-timed it. nocfbot-0001 alone (your xmin !=3D xmax idea plus the MULTI skip) is unchanged and passes your test in 4 of 4 runs. Thanks for the repro. Regards, Manu --===============3859942140528650571== Content-Type: text/plain Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="nocfbot-0002-fixed-abort-check-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