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 1guc9f-0002zy-C7 for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Feb 2019 11:59:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1guc9e-0002ds-2k for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Feb 2019 11:59:42 +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 1guc9d-0002dK-R6 for pgsql-hackers@lists.postgresql.org; Fri, 15 Feb 2019 11:59:41 +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 1guc9b-0001As-DR for pgsql-hackers@postgresql.org; Fri, 15 Feb 2019 11:59:41 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2: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 83E9EA147A; Fri, 15 Feb 2019 12:59:37 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de [80.241.56.117]) (amavisd-new, port 10030) with ESMTP id vy7WC1g2gSpi; Fri, 15 Feb 2019 12:59:32 +0100 (CET) From: Antonin Houska To: Michael Paquier cc: Bruce Momjian , Alvaro Herrera , pgsql-hackers@postgresql.org Subject: Re: Incorrect visibility test function assigned to snapshot 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> Comments: In-reply-to Michael Paquier message dated "Thu, 14 Feb 2019 16:13:13 +0900." MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 15 Feb 2019 13:01:29 +0100 Message-ID: <16034.1550232089@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Michael Paquier 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. >=20 > > @@ -615,6 +615,8 @@ SnapBuildInitialSnapshot(SnapBuild *builder) > >=20=20 > > TransactionIdAdvance(xid); > > } > > + /* And of course, adjust snapshot type accordingly. */ > > + snap->snapshot_type =3D SNAPSHOT_MVCC; >=20 > 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 functi= on look like it can handle all snapshot types. If adding an argument, I'd pref= er 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)); > >=20=20 > > + /* > > + * 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 =3D SNAPSHOT_MVCC; >=20 > Okay for this one, however the comment does not add much value. o.k. I don't insist on using this comment. --=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