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 1x78nQ-000000007vI-2TlN for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Sep 2026 09:52:49 +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 1x78nP-00000003QGx-31Ft for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Sep 2026 09:52:47 +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 1x78nP-00000003QGp-1li6 for pgsql-hackers@lists.postgresql.org; Thu, 17 Sep 2026 09:52:47 +0000 Received: from mail-wr2-x10.google.com ([2a00:1450:4864:30::10]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x78nL-00000000yzZ-3OxW for pgsql-hackers@lists.postgresql.org; Thu, 17 Sep 2026 09:52:47 +0000 Received: by mail-wr2-x10.google.com with SMTP id ffacd0b85a97d-4834977ae75so357396f8f.3 for ; Thu, 17 Sep 2026 02:52:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1789638764; x=1790243564; darn=lists.postgresql.org; h=message-id:date:content-transfer-encoding:content-type:mime-version :comments:references:in-reply-to:subject:cc:to:from:from:to:cc :subject:date:message-id:reply-to:content-type; bh=5SFIgQhHoB32B4mZKujF2h5JFuB8TsBtfW/WuB1oOAI=; b=E1EXNssBdf6SBklTXSMpDm9avOE1rmv1RU3YYXOZRw4YWz2HLnFTrfpOJrRwb9dtYK 6amBLL7D8Vg5w/2qIJ/8r8MzFCOxM9BDjKmNp9RhCoHycHho0M8sxQ3Pugx2xfwpq+wp 7loRNdhMFeUOUa6dhCckRco+JS2g7YywzOCjmIYrHwwKAxkfU84RNOS4sPWf+eu62zAC wM+pcUqNW+OhCCZpOcKyxPja0RcQzzsQ2NC1LuNz3KjYbByBM95s2YyLccBpVAB0sXop 4M5NsDDb9aCsXso3n1Cvw5Un5vm9HVoFmMvUrQvJH5Oaf4kcc772lVOKdQgd1ra/6hnM Vn4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789638764; x=1790243564; h=message-id:date:content-transfer-encoding:content-type: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 :content-type; bh=5SFIgQhHoB32B4mZKujF2h5JFuB8TsBtfW/WuB1oOAI=; b=QWffps/Tsm0/8HmzuuwicH0tErX2QZ0kztLVwIEEJ7NdpP43cSCzNWRETjQ+xdyQ+X 6HinXj57zf+1k4MKplfCNEZYgrWmRRgxN12askIbAk24MeFBNnS2EFRu9x+lXjGU8Ils CZXdN19RxrikhTGGi+ILWjCQtVuLIDuzFSqGtem3TkFDWntmMa7W03xTVWEw7on6WnYp byiOD68xONxa5VyFj6DuIeXXEzDJF4+Hx5aBZLAA9Dldlu7gSsx1Sjl36eJFeyjtQK6n r08yyAE1bb0knurc40282voBI9Ejz9ejTssnzZqVymwbqswKzsDHaHZY4RngobWthRRE TSPw== X-Forwarded-Encrypted: i=1; AKwUvBys3QJRZsv/laVVoJpfVbC8OycVA+PNRjjkiyj2nM59psuFCEsfD+hOoPtWWzWhUhVYMQq5inCuh0WKeiV6@lists.postgresql.org X-Gm-Message-State: AFuF++kpDIxaWZ8c7wO2f99saCEbnU4vOClCcMqCLEjEOC8Pq7y4xewL xmN1WQjIN0oMevEqauIqHrtMsDl1pxhICHuB9a2qrWoL4cwUpM/DW0YyWoRm0kGryCs64vbHf19 sS9ZRH88= X-Gm-Gg: AYBFou1AVVRWZccOofBiodt47vmZI8qH9eLR0WRxPGxr+XUhh9/stdNHHVoUmyviuY8 Qdz72z14vKqhT7Eb2PhiSWyzdH81Me3sxPi8FPvveQ3EwxSl3vQCOMxMKgm5ZKJM2QyhR7tnD6U yCPZ07VRm0GFLtDpuhmoMPmfu3uuA6Gj9PelKdKFoiw3ue3KbmlFc6IALDMi1N//UN/Ek2HJAWu r9OH9LrHKWd7M2X2y8jbS8c6dQ80wqf29bKIchk2J+w6AkC0MaztGmukIFk3Zp+i57hhq0ngNPS AlfrN6TJRsjZ+uVAyOIgg2S7HKmXmi0MIWVEMjKthl5qlmVB1ZnkzIP6pcnzfwSwGzh/3TRjC52 54W5IY4ypTwX70qRqtlCxcjHGOWuOba13seSJtBGCa0VMaB2f8Say6X4ZbYV6Cpuy0tt3K0YGNa n4SqiiVwPIOTavy526qvvnr3Afw7CbuC33KwnmJM/k6oOdKzD6eermmtsguMymX1sm+NGGEwEGL YczYjfW4Xjh X-Received: by 2002:a05:6000:41c7:b0:487:403:84f1 with SMTP id ffacd0b85a97d-4870cee9015mr15843797f8f.9.1789638763791; Thu, 17 Sep 2026 02:52:43 -0700 (PDT) Received: from localhost (109-81-170-190.rct.o2.cz. [109.81.170.190]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4870bef7659sm15053673f8f.3.2026.09.17.02.52.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2026 02:52:43 -0700 (PDT) From: Antonin Houska To: "Zhijie Hou (Fujitsu)" cc: alvherre@kurilemu.de, "pgsql-hackers@lists.postgresql.org" , Mihail Nikalayeu , Andres Freund Subject: Re: Race conditions in logical decoding In-reply-to: References: Comments: In-reply-to "Zhijie Hou (Fujitsu)" message dated "Wed, 16 Sep 2026 07:59:58 -0000." 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: Thu, 17 Sep 2026 11:52:42 +0200 Message-ID: <14388.1789638762@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Zhijie Hou (Fujitsu) wrote: > On Wednesday, September 9, 2026 6:20 PM =C3=81lvaro Herrera wrote: > > On 2026-Aug-22, Zhijie Hou (Fujitsu) wrote: > > >=20 > > > Besides, just to confirm one note: IIUC, for exported snapshots by > > > logicalrep, a transaction could be treated as committed while still in > > > PGPROC, while concurrent MVCC snapshots still see it as in progress w= hich > > looks inconsistent. > > > I understand that waiting for ProcArray removal in the general case > > > could deadlock against synchronous replication, so it's probably > > > acceptable to leave it unchanged for internal usage in active replica= tion processes. > >=20 > > OK. TBH I'm somewhat unease about this inconsistency; I wondered about > > doing the CLOG-based test only in sync replication and using XidIsInPro= gress > > otherwise, but didn't really try (which is to say: I'm not even sure if= it's > > _possible_ at all.) >=20 > I experimented with this a bit and confirmed that the inconsistency exist= s, > though it doesn't affect REPACK (CONCURRENTLY), the command takes an excl= usive > lock on the table when switching the old and new heap, which forces any > concurrent transactions on that table to finish first. However, the > inconsistency can be observed if a user directly uses the exported snapsh= ot, as > shown in the attachment (generated with AI assistance). ... > diff --git a/src/test/recovery/t/058_exported_snapshot_pgproc_window.pl b= /src/test/recovery/t/058_exported_snapshot_pgproc_window.pl > new file mode 100644 > index 00000000000..4b6d8dd8353 > --- /dev/null > +++ b/src/test/recovery/t/058_exported_snapshot_pgproc_window.pl > @@ -0,0 +1,293 @@ > +# Copyright (c) 2026, PostgreSQL Global Development Group > +# > +# Test that a snapshot exported by CREATE_REPLICATION_SLOT ... (SNAPSHOT > +# 'export') can treat a transaction as committed while that transaction = is > +# still in the procarray, so that concurrent MVCC snapshots taken by oth= er > +# backends still see it as in progress. As far as I understand, what you demonstrate here is that different backends can have a different view of the database. Isn't that pretty common situati= on? What I'd consider a problem would be a single backend (and single transacti= on) seeing inconsistent data. --=20 Antonin Houska Web: https://www.cybertec-postgresql.com