pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Antonin Houska <ah@cybertec.at>
To: Michael Paquier <michael@paquier.xyz>
Cc: 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, 15 Feb 2019 13:01:29 +0100
Message-ID: <16034.1550232089@localhost> (raw)
In-Reply-To: <20190214071313.GF2366@paquier.xyz>
References: <23215.1527665193@localhost>
	<20180530132854.tkv37qiamepu3slh@alvherre.pgsql>
	<20180623151856.GG21575@momjian.us>
	<23440.1549623545@localhost>
	<20190214071313.GF2366@paquier.xyz>

Michael Paquier <michael@paquier.xyz> wrote:

> On Fri, Feb 08, 2019 at 11:59:05AM +0100, Antonin Houska wrote:
> > Sorry, I forgot. Patch is below and I'm going to add an entry to the
> > next CF.
> 
> > @@ -615,6 +615,8 @@ SnapBuildInitialSnapshot(SnapBuild *builder)
> >  
> >  		TransactionIdAdvance(xid);
> >  	}
> > +	/* And of course, adjust snapshot type accordingly. */
> > +	snap->snapshot_type = SNAPSHOT_MVCC;
> 
> Wouldn't it be cleaner to have an additional argument to
> SnapBuildBuildSnapshot() for the snapshot type?  It looks confusing to
> me to overwrite the snapshot type after initializing it once.

I'm not sure. SnapBuildBuildSnapshot() only creates snapshot for the logical
replication purposes and the "snapshot_type" argument would make the function
look like it can handle all snapshot types. If adding an argument, I'd prefer
a boolean variable (e.g. "historic") telling whether user wants
SNAPSHOT_HISTORIC_MVCC or SNAPSHOT_MVCC. But that may deserve a separate
patch.

As for the bug fix, I think the additional assignment does not make things
worse because SnapBuildInitialSnapshot() already does overwrite some fields:
"xip" and "xnt".

> > @@ -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;
> 
> Okay for this one, however the comment does not add much value.

o.k. I don't insist on using this comment.

-- 
Antonin Houska
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26, A-2700 Wiener Neustadt
Web: https://www.cybertec-postgresql.com




view thread (12+ messages)  latest in thread

Message-ID: <16034.1550232089@localhost>
Permalink:  ../16034.1550232089@localhost/
Also on:    postgresql.org/message-id/16034.1550232089@localhost

 · 

reply

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, michael@paquier.xyz, bruce@momjian.us, alvherre@2ndquadrant.com
  Subject: Re: Incorrect visibility test function assigned to snapshot
  In-Reply-To: <16034.1550232089@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