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 1x7XiE-00000000TC4-22Ui for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Sep 2026 12:29:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1x7XiD-00000000u2N-2bP4 for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Sep 2026 12:29:05 +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.98.2) (envelope-from ) id 1x7XiC-00000000u2F-35I3 for pgsql-hackers@lists.postgresql.org; Fri, 18 Sep 2026 12:29:05 +0000 Received: from fout-a5-smtp.messagingengine.com ([103.168.172.148]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x7Xi9-000000001lx-0LyB for pgsql-hackers@lists.postgresql.org; Fri, 18 Sep 2026 12:29:04 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id 7C002EC0210; Fri, 18 Sep 2026 08:28:58 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Fri, 18 Sep 2026 08:28:58 -0400 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=fm3; t=1789734538; x= 1789820938; bh=y3Bj251Qx4axatvuwnvzTd+LGa8Q+YfPVXo7oh8EJQE=; b=e M5X+LUsFog3VaTXCFdsZhr3/TLnDwrAMPJ5ttEVqfx97kjCZ539H5rXss0t92rLP iqUUiVYTdpFWAimmBD+bXUgELjs1PIVZE9jvIN0CPdySw/ihA7/Cp/MCjElkVQeO bu3FOP5EbRHQJde7KW91W7i4lCGIafauQ55OXu0qR+5Wh8VNCmb8CR1Giqkau/RS bccVUvDCSLK+mvkMXOobnwKY8/KY9mwM6JAQ5iKvADPuRx4StfVwPmHR10Cq3o/L l2QbKZ2OlqnyZ24E6Enza8+2PYnVV2Ex8qodlLhIJMl8RrISntC6N+7knfpKeHPx e6Rx9WSQ9TM6MIl2EmT/Q== 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=fm1; t=1789734538; x=1789820938; bh=y 3Bj251Qx4axatvuwnvzTd+LGa8Q+YfPVXo7oh8EJQE=; b=OhhHcrL3u05U8zjXX SQj9qrJOEfzyOJibZUH87LWqb+ntDlc0tUFKV/ydMrtfBqG/wsUQJVE5O2yZpUSH epejiocm0aUaxV3lo152d7RDDyxiw0gtKqm6VDPFIF10qPL6y9lpsoksD1ib+Rvq xAWzUwGW0kODvVPpLgEywozI8cQaXAV0cfF9sukXC1OoEYJVrbcMk7uKMdLhCpws Fv7tbaeAYYhtHHNHtoVB5l2CFm6pEtbi5wA5q5GwsmAdrhsJOV08/jZcT2WQ/dGs WiuHGzaj83lQYrwuDQzeYovqw+42EIzQvOsXtC5Mws3onMA8a3LTU9T/52am6fR0 qt2mw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEpaY8JHDv/1c3RZboOO9w/ysLulCcJDdqeoCwRhX5QWEkOkyXMuwqF59CjxDFbnl V6Vkyx8LZ9QXeK2yCWuu2o5HVTPrZW9j9QPc4OdHuPG5kS/4NXWtodUQlZZhmd0/0l2viu a47n1aQWf/9Jvnq6Lx8F5i/+LA64W6cK1pg3x2mXGur9b0yd1xe8ToKnyKlk3Qe6h8k2WZ ecW9lTYAv//VjsP6P/xsUGf9sBYQmiyq3sYIJRAjIVejtksUJwRk7MkEV9zuHLVxUEEHnk /egkK0ujz57S5Pvkg4Ihp9gu+GIxljitAXhpMxR4jPc8Rlav1s/UL2OTUu+ZoKX+9VGkW8 f3b3c8OZiySRZOXlPrI69PxdYYeQJP7dlYKwGW+Dtr9eDBDHYlqUj58FtlJ1L1X1B9BKSP ENkGEyRtGwg5xudEAiaCnRsBytosIebor3AnNDu3FihTsjjMrWR51sq9ASUq4T78gnBdRF ico1P9KffIRthT8AVlQZgTWWrAL6AynjfAXW6IDLF248VR59NY4Qw8HWUWtkVM4FAToodj EnC0uobJ1ZXWcno7+cWZiBzYBWRgOF1PKgHtvg/YB+hxisNDSQRxDIV15Sm7RUy4m0MtjA gxsBAP0Op1eg2a+PYJtx7rj5+VctZ1UCMuF/exq5YC28Tpzt/8uzwpmQGcmA X-ME-Proxy: Feedback-ID: ie3de48e3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 18 Sep 2026 08:28:57 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kurilemu.de; s=schmee; t=1789734535; bh=bTI2/ggOqEg5wSlAivtJ4O8EGQjgkSTmlHKQNUQi6Tg=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=awMhtU40BtFs2/Qe3Da2+N8+rRKFzwDMg0GXTWhrrZsueziWyo6u7uOIiyzE67KGQ gNmZ6uKh+0eEuudu3DqB2sXCW3QoQIptXo081JLtiWGtUC6eV/sifmPBLiq7gcX10p Bk9OyCDfW4g9GCb+Y06OvV0RqM1q9Ewrf+gqubeVF6DjZ4f14hu+MuVuuxoPRlF7Ny dSgeZdLOiurNTooA9sccC/QTWTBGZXmQZ1Koj5nNidb1l4o4z5S2/1yHiAhR0YFhfx 9t+h7ymNkKQRxS1WsSLsD/pCZPhv0NB6CX65MKLLntIhGhd9HlxkYQ/Sw4hNNtZhLm K6pDtKd/LSneA== Received: by ida.kurilemu.internal (Postfix, from userid 1000) id 14613B0008E; Fri, 18 Sep 2026 14:28:55 +0200 (CEST) Date: Fri, 18 Sep 2026 14:28:55 +0200 From: Alvaro Herrera To: Antonin Houska Cc: Rui Zhao , Andres Freund , pgsql-hackers@lists.postgresql.org, Mihail Nikalayeu Subject: Re: Race conditions in logical decoding Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8247.1789634255@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2026-Sep-17, Antonin Houska wrote: > > + for (int i = 0; i < nrunning; i++) > > + { > > + TransactionId running_xid = running->xids[i]; > > + > > + if (bsearch(&running_xid, snap->xip, snap->xcnt, > > + sizeof(TransactionId), xidComparator) != NULL) > > + XactLockTableWait(running_xid, NULL, NULL, XLTW_None); > > + } > > + } > > I don't understand why you check all transactions in procarray, instead of > only those in snap->xip. Hmm, but he does: for all the transactions that are running, only those that are found by bsearch() in the snap->xip array are waited for. Is that not what we want? I guess we could do it the other way around: iterate for each item on snap->xip and search for those in running->xids. Is that what you suggest? We don't know offhand which array is largest; it would be better to iterate on the smaller one and bsearch the largest. (Or maybe if both are sorted, scan them simultaneously.) I don't find any reference to say that running_xid is sorted. I don't understand these two paragraphs: * A subtransaction is covered by its top-level transaction, which is in * snap->xip as well, or was purged from it because it is below xmin and * thus finished long ago. * * Historic snapshots do not need this: between xmin and xmax they rely on * xip alone, and transactions below xmin had left the procarray by the * time the xl_running_xacts record that set xmin was written. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "After a quick R of TFM, all I can say is HOLY CR** THAT IS COOL! PostgreSQL was amazing when I first started using it at 7.2, and I'm continually astounded by learning new features and techniques made available by the continuing work of the development team." Berend Tober, http://archives.postgresql.org/pgsql-hackers/2007-08/msg01009.php