Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gs3qW-0007NR-Sx for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Feb 2019 10:57:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gs3qU-00043H-9i for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Feb 2019 10:57:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gs3qU-00043A-2W for pgsql-hackers@lists.postgresql.org; Fri, 08 Feb 2019 10:57:22 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gs3qR-0004R3-Ap for pgsql-hackers@postgresql.org; Fri, 08 Feb 2019 10:57:21 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 7E626A10B5; Fri, 8 Feb 2019 11:57:17 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id GcextWrcwC60; Fri, 8 Feb 2019 11:57:12 +0100 (CET) From: Antonin Houska To: Bruce Momjian cc: Alvaro Herrera , pgsql-hackers@postgresql.org Subject: Re: Incorrect visibility test function assigned to snapshot In-reply-to: <20180623151856.GG21575@momjian.us> References: <23215.1527665193@localhost> <20180530132854.tkv37qiamepu3slh@alvherre.pgsql> <20180623151856.GG21575@momjian.us> Comments: In-reply-to Bruce Momjian message dated "Sat, 23 Jun 2018 11:18:56 -0400." MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Date: Fri, 08 Feb 2019 11:59:05 +0100 Message-ID: <23440.1549623545@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Bruce Momjian wrote: > On Wed, May 30, 2018 at 09:28:54AM -0400, Alvaro Herrera wrote: > > On 2018-May-30, Antonin Houska wrote: > >=20 > > > In the header comment, SnapBuildInitialSnapshot() claims to set > > > snapshot->satisfies to the HeapTupleSatisfiesMVCC test function, and = indeed it > > > converts the "xid" array to match its semantics (i.e. the xid items e= ventually > > > represent running transactions as opposed to the committed ones). How= ever the > > > test function remains HeapTupleSatisfiesHistoricMVCC as set by > > > SnapBuildBuildSnapshot(). > >=20 > > Interesting. While this sounds like an oversight that should have > > horrible consequences, it's seems not to because the current callers > > don't seem to care about the ->satisfies function. Are you able to come > > up with some scenario in which it causes an actual problem? >=20 > Uh, are we going to fix this anyway? Seems we should. Sorry, I forgot. Patch is below and I'm going to add an entry to the next C= F. --=20 Antonin Houska Cybertec Sch=C3=B6nig & Sch=C3=B6nig GmbH Gr=C3=B6hrm=C3=BChlgasse 26, A-2700 Wiener Neustadt Web: https://www.cybertec-postgresql.com --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=snapshot_type.patch diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index 2f185f7823..3394abb602 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -615,6 +615,8 @@ SnapBuildInitialSnapshot(SnapBuild *builder) TransactionIdAdvance(xid); } + /* And of course, adjust snapshot type accordingly. */ + snap->snapshot_type = SNAPSHOT_MVCC; snap->xcnt = newxcnt; snap->xip = newxip; diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c index 6e02585e10..bc0166cc6f 100644 --- a/src/backend/utils/time/snapmgr.c +++ b/src/backend/utils/time/snapmgr.c @@ -1502,6 +1502,13 @@ ImportSnapshot(const char *idstr) */ memset(&snapshot, 0, sizeof(snapshot)); + /* + * Do not rely on the fact that SNAPSHOT_MVCC is zero. (The core code + * currently does not use this field of imported snapshot, but let's keep + * things consistent.) + */ + snapshot.snapshot_type = SNAPSHOT_MVCC; + parseVxidFromText("vxid:", &filebuf, path, &src_vxid); src_pid = parseIntFromText("pid:", &filebuf, path); /* we abuse parseXidFromText a bit here ... */ --=-=-=--