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.96) (envelope-from ) id 1w4c32-002MfR-1m for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Mar 2026 09:58:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w4c2z-00GnmC-2w for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Mar 2026 09:58:10 +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.96) (envelope-from ) id 1w4c2z-00Gnm3-1u for pgsql-hackers@lists.postgresql.org; Mon, 23 Mar 2026 09:58:10 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w4c2x-00000000bZL-3I6k for pgsql-hackers@lists.postgresql.org; Mon, 23 Mar 2026 09:58:08 +0000 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-486b9675d36so31998525e9.0 for ; Mon, 23 Mar 2026 02:58:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1774259881; x=1774864681; darn=lists.postgresql.org; h=message-id:date:content-transfer-encoding:mime-version:comments :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gn5PoO05E16Ye0YipAtGSKALpAqRL6HMwLt9oksXVLY=; b=S/nW7Ycoh9BQbupI2rT8UAVPJjvky1ug84k6et9GE8zr9MfBsfnJdfcFrFcSKLyXUf g36OK536PNt0qnTfHm7VV/1+Kj3GSh1yiZi/1gqXEkjgwzFvEXkEsZJKr75sX3F6QlCE 2OkbbrdBX2wFJr4zMGUYdrgc01+W7wbJKr6Aq5pViIYTJ68Qq/3x4CCAJdOGErfm4Xhf twXsBeJb7Ijtpd7bTsfq9IkfVacP8SSPBWoM7uaLWbwr5mXOug+LkuGFJp7or956bmB6 v/nczXZ7/WAxl2PJTr1u4ryQwU0H305mvkFi2SDY1yPXtqVI/Iy2i1ZCEXkwpghPeOog 7USw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774259881; x=1774864681; h=message-id:date:content-transfer-encoding:mime-version:comments :references:in-reply-to:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gn5PoO05E16Ye0YipAtGSKALpAqRL6HMwLt9oksXVLY=; b=T/aE723W11ysUHYXPk8bngOvR6NAGGkytQklhRQJN+oDHAXXCg/X2yVDzI+UPF0zAP k4DPAP5CICQ0vCFK4b+E1A+4Rc8Sk5Us8XdK4Xg8DBG6XbaWC/e+uQG0Usyj3LPQ+9Ir mwD1jSZ9g4/y/7g1CAGf+Hm4iBKqX9jF7mQ+peDBYYcddeAxp1IST+q+/Yc+v2UKSBte FnOS4Tqab9gcwQtH9TCVuxjlKlIWsJp6xNXj9spvfQt1v2vo5Bj6n/L8uLz6JyFSLi+h Hx3pgfT734c7RmukDASbxgJSGB0lmiGcg6FeIU3pd8qcgwdG98JuXRpXiJMvJk4+1zu2 tFcw== X-Forwarded-Encrypted: i=1; AJvYcCUw1liwA5HwXHWeHX7zIKcJnm5bYr+If7NrOxl8YgYyyOgYgwOemQ6u70f2byvqFC4SXDgFDYbPn9ECqcG5@lists.postgresql.org X-Gm-Message-State: AOJu0Yzn/TB3zkJCTA1GOG17zZQi3pliS96s0uC8Lv/jBZWaM90qsU89 jcOZBt/IQV497oQlvykNvJ9e8VajaibK/jgt+9RnrAXZufXpWDHP9rVMh20a6+MwjmfIJex2q6s IcgGU X-Gm-Gg: ATEYQzwAiE1jmtpZhO0Z31ItlbzJ9pvHa1UP6PymwM4p3SA3z8STzveY0FErnQ0xdqj Jmvd39GWcwOJmqOhpnK7RIAZS73yYteFFvFKCUWI7kzn12/lFlrqdkxnL3dDAiBKiCuqlbGzigh hT/NoLaxZzQXNPSFr1H30TqG5hfbU24BDqUs0b2uH95IiA305ck9I4c+acs8RlUdkYpE3al80E/ OvoUlrNj6NuhWq2f56pdjlsLYbdxmpnlbZGXc6emojqYZCdGvuO4L8tptgAt++rvvFxOcBT/9+u MSTY2aI12gXpB2CdRW5ur2LEvxpokD+sC3lDCCUC/wV8CMFEckEQuLCM913HWlYplkVWatrDoIQ GPKK5o0dtt/Zn+4ft/X6KlMM73qXbaWT/5Dkj0dEYezJ9icZK7wSpGi0hwG/T9FNEzq+696c6u0 Zju3xzphV+6Jkvw2gnXQZeUgHrksTHADkuLsnS X-Received: by 2002:a05:600c:548e:b0:47e:e2ec:9947 with SMTP id 5b1f17b1804b1-486ff029336mr157103205e9.33.1774259881229; Mon, 23 Mar 2026 02:58:01 -0700 (PDT) Received: from localhost (109-81-168-142.rct.o2.cz. [109.81.168.142]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48703e26408sm281176795e9.11.2026.03.23.02.58.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 02:58:01 -0700 (PDT) From: Antonin Houska To: alvherre@kurilemu.de cc: Andres Freund , pgsql-hackers@lists.postgresql.org, Mihail Nikalayeu Subject: Re: Race conditions in logical decoding In-reply-to: <202603201543.t6gxppyyk66p@alvherre.pgsql> References: <202603201543.t6gxppyyk66p@alvherre.pgsql> Comments: In-reply-to =?us-ascii?Q?=3D=3Futf-8=3FQ=3F=3DC3=3D81lvaro=3F=3D?= Herrera message dated "Fri, 20 Mar 2026 16:55:52 +0100." X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 23 Mar 2026 10:58:00 +0100 Message-ID: <10225.1774259880@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =C3=81lvaro Herrera wrote: > I realized that I hadn't posted the patch version I described somewhere > downthread. Here it is, as 0001. >=20 > While thinking about it for posting just now, I wondered if it would > work to consider that any transaction whose commit record has been > decoded but which nevertheless gets a true return from > TransactionIdIsInProgress(), just is not committed yet and so should be > omitted from the xip array of the snapshot. That is, if it's > still-running, then we just don't copy it into the output snapshot. > That's implemented as 0002 here. This seems somehow less controversial, > as we don't have to test TransactionIdDidCommit() for a transaction that > we haven't seen as not-running per PGPROC; and it should also be faster, > because we don't have to wait for anybody to commit.However it gives > me pause that perhaps the snapshot would not be fully correct. (Indeed > there are a few failing tests in the subscription suite). I recall that in some of the patches for REPACK enhancements (snapshot switching, MVCC-safety, etc.) for v20 I had a problem with TransactionIdIsInProgress(). In particular, I tried to add a flag like PROC_IN_VACUUM, to limit the REPACK's impact on VACUUM xmin horizon. The problem was that TransactionIdIsInProgress() compares the xid to RecentXmin before accessing CLOG. IIRC VACUUM's RecentXmin skipped the xid = of REPACK and considered its xid not in progress anymore, but since the transaction wasn't committed yet per CLOG, VACCUM incorrectly considered it aborted (per HeapTupleSatisfiesVacuumHorizon). Thus I imagine that with 0002, transaction having PROC_IN_SAFE_IC set might= be added to the snapshot's list of committed transactions although its still in progress. > Failing other ideas, I think we should just go with 0001. We'd need more > commentary on why is TransactionIdDidCommit() OK, when we haven't > scanned PGPROC for that xid, though. Mihail already told me that I should consider adding this patch to the CF. I said that I'm aware of its importance (because REPACK probably exposes the = bug more than logical replication does) and that I'll remind you if you happen = to forget about it. However I thought that fixes of existing bugs are not subj= ect to feature freeze, so I did not bring it up yet. --=20 Antonin Houska Web: https://www.cybertec-postgresql.com