From: Antonin Houska <ah@cybertec.at>
To: Bruce Momjian <bruce@momjian.us>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Incorrect visibility test function assigned to snapshot
Date: Fri, 08 Feb 2019 11:59:05 +0100
Message-ID: <23440.1549623545@localhost> (raw)
In-Reply-To: <20180623151856.GG21575@momjian.us>
References: <23215.1527665193@localhost>
<20180530132854.tkv37qiamepu3slh@alvherre.pgsql>
<20180623151856.GG21575@momjian.us>
Bruce Momjian <bruce@momjian.us> wrote:
> On Wed, May 30, 2018 at 09:28:54AM -0400, Alvaro Herrera wrote:
> > On 2018-May-30, Antonin Houska wrote:
> >
> > > 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 eventually
> > > represent running transactions as opposed to the committed ones). However the
> > > test function remains HeapTupleSatisfiesHistoricMVCC as set by
> > > SnapBuildBuildSnapshot().
> >
> > 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?
>
> 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 CF.
--
Antonin Houska
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26, A-2700 Wiener Neustadt
Web: https://www.cybertec-postgresql.comAttachments:
[text/x-diff] snapshot_type.patch (1.1K, ../23440.1549623545@localhost/2-snapshot_type.patch)
download | inline diff:diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.cindex 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.cindex 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 ... */
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: ah@cybertec.at, bruce@momjian.us, alvherre@2ndquadrant.com
Subject: Re: Incorrect visibility test function assigned to snapshot
In-Reply-To: <23440.1549623545@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox