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 1vj0hK-003ggy-1L for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Jan 2026 19:50:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vj0hJ-00ETvd-1g for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Jan 2026 19:50:29 +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.96) (envelope-from ) id 1vj0hJ-00ETvV-0b for pgsql-hackers@lists.postgresql.org; Thu, 22 Jan 2026 19:50:29 +0000 Received: from fout-a2-smtp.messagingengine.com ([103.168.172.145]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vj0hG-000000000gY-3pXG for pgsql-hackers@lists.postgresql.org; Thu, 22 Jan 2026 19:50:29 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id DFF45EC0749; Thu, 22 Jan 2026 14:50:25 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Thu, 22 Jan 2026 14:50:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kurilemu.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to; s=fm1; t=1769111425; x= 1769197825; bh=JxyCSOeeX4nZKcr3IISGkmNm/XpJIt0FOrJiDfTfDgM=; b=Y gM9FD2xt6DMiUohnlqFq9jP6SHhskZ0hFLaa/v92RmZJWvcN7Pc3I+2HBZV5l2cK 4F5aGIEgCKMp4luADXpVuIrNl8B3LJ8DDwp6xaIFV6m59b5F5oMQ10xmLavdfKTv OhSUEqAJ1t6/3Yjlk2SsuyVz04KardgoaIlqrDg0XFkxwhYhQu0ptwmA8ua1LzIC 35PBYDPjv0CHoOBVsleKqSXJQWb5gQxPN5avJRj/3jlwFoGDEsxE+cJbJIgN1sZQ QV4qYEgqbSqTnzayJ5pAl29PDoTATMYtwRJi3O2vGAJz3UVWBSezeDi3mDvc1pke CDr8XGIcis8hCv3rVu8og== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1769111425; x=1769197825; bh=J xyCSOeeX4nZKcr3IISGkmNm/XpJIt0FOrJiDfTfDgM=; b=fnv478ehM33KuGZeo IA6cXDvYQB+TdcO/fJmlvpnUk2WYdR+8PElJDOX1Cz8O/yRjdjJ2WAM17J5lhpnI l9gVhhQDic+heQOwUZGqT6fqWR2B6rToIfRrVJFkQkGfwB6aid6fxpxoh4RlNqia pRe8Z2o91N3OuoFMIQyUZlzS0vMinTyxY4bQRBh6h1qtA7ugmHqT9GN7wlufdF9o xawVpORymc+biAHxZ/p58AkBjo5oRbGa8MjEoR3c6t8NM0cjBbsQv+Qd7/OvT1eS 2kZMQWVvmD0HjVrdGouRw8J5fqhbD9lvYEBFP7cS95zRAyi6xs0RVP03ckM9qhFJ mbRBg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddugeejtdegucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheplmhlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsehkuhhrihhlvghmuhdruggvqeenucggtf frrghtthgvrhhnpeetuedvheffkeevgfeuheevteevkefggedttdeufeeuheduuddthfef fffhjeefffenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgv sehkuhhrihhlvghmuhdruggvpdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpoh huthdprhgtphhtthhopegrnhgurhgvshesrghnrghrrgiivghlrdguvgdprhgtphhtthho pegrhhestgihsggvrhhtvggtrdgrthdprhgtphhtthhopehmihhhrghilhhnihhkrghlrg ihvghusehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrshes lhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: ie3de48e3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Jan 2026 14:50:25 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kurilemu.de; s=schmee; t=1769111422; bh=MwpCac1wbjgYFnJeEgoXRIN7OFhO4Ow1PX7jlKxauKg=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=aY6wTqnLBh5+oKvVOO0MhvekcGXJyiMvGdCysf1li2udkBbnaNK2q8aVOANgSKeQw W67vmpTaJZFdEMugIrAYzpfF05CvaM5Fi5yQD5t2oXl7CPulAMt7WfB1O2ASHdA/qy g63cpd6ew6cP8lJkU9LrVfM8PhkpoE3qRDuC7Kh+8JnzIeiRHgmPctcddhzhni9qS6 W2K6FhhqkpibswEx0vYnrK7Jp3Y9CfsRT1GmdZDJDqdMU8+1Y5vu5nxfK6sd8N7IkZ /B2arnh6vfS8PcuflNnpD4A4V+NIBzJfar5IS0j3NPDHyMwcqfRxGrWapvbOBEqzR4 Zpz8jIhPJd9aA== Received: by schmee.kurilemu.internal (Postfix, from userid 1000) id A5EB764; Thu, 22 Jan 2026 20:50:22 +0100 (CET) Date: Thu, 22 Jan 2026 20:50:22 +0100 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Antonin Houska Cc: Mihail Nikalayeu , Andres Freund , pgsql-hackers@lists.postgresql.org Subject: Re: Race conditions in logical decoding Message-ID: <202601221939.rs5bossvsnfb@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202601221804.nbrvjquik7qp@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2026-Jan-22, Álvaro Herrera wrote: > On 2026-Jan-22, Antonin Houska wrote: > > > Do you mean replace > > > > if (unlikely(!TransactionIdDidCommit(builder->committed.xip[i]))) > > > to > > > > if (unlikely(TransactionIdIsInProgress(builder->committed.xip[i]) || !TransactionIdDidCommit(builder->committed.xip[i]))) > > > > This way the synchronous replication gets stuck, as it did when I tried to use > > XactLockTableWait(): subscriber cannot confirm replication of certain LSN > > because publisher is not able to even finalize the commit (due to the waiting > > for the subscriber's confirmation), and therefore publisher it's not able to > > decode the data and send it to the subscriber. BTW, the reason XactLockTableWait and TransactionIdIsInProgress() cause a deadlock in the same way, is that they are using essentially the same mechanism. The former uses the Lock object on the transaction, which is released (by the ResourceOwnerRelease(RESOURCE_RELEASE_LOCKS) call in CommitTransaction) after RecordTransactionCommit() has returned -- that is, after the wait on a synchronous replica has happened. XactLockTableWait does an _additional_ test for TransactionIdIsInProgress, but that should be pretty much innocuous at that point. One thing that I just realized I don't know, is what exactly are the two pieces that are deadlocking. I mean, one is this side that's decoding commit. But how/why is that other side, the one trying to mark the transaction as committed, waiting on the commit decoding? Maybe there's something that we need to do to _that_ side to prevent the blockage, so that we can use TransactionIdIsInProgress() here. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/