Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fNvUO-0007GB-Ao for pgsql-hackers@arkaria.postgresql.org; Wed, 30 May 2018 07:25:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fNvUM-00007b-Sn for pgsql-hackers@arkaria.postgresql.org; Wed, 30 May 2018 07:25:42 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fNvUM-00007R-IB for pgsql-hackers@lists.postgresql.org; Wed, 30 May 2018 07:25:42 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fNvUF-0004vV-07 for pgsql-hackers@postgresql.org; Wed, 30 May 2018 07:25:41 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 4326441195 for ; Wed, 30 May 2018 09:25:30 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id Ne-YoXtKwKgu for ; Wed, 30 May 2018 09:25:29 +0200 (CEST) From: Antonin Houska To: pgsql-hackers@postgresql.org Subject: Incorrect visibility test function assigned to snapshot MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 30 May 2018 09:26:33 +0200 Message-ID: <23215.1527665193@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 eventua= lly represent running transactions as opposed to the committed ones). However t= he test function remains HeapTupleSatisfiesHistoricMVCC as set by SnapBuildBuildSnapshot(). I suppose this is a bug: HeapTupleSatisfiesHistoricMVCC expects the committ= ed transactions in the snapshot->subxip array, however the snapshot returned by SnapBuildInitialSnapshot() leaves this array empty. And even if the function used snapshot->xip, it'd find the running transactions there instead of tho= se committed. This is what I propose as a fix: diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/repl= ication/logical/snapbuild.c new file mode 100644 index 4123cde..53e8b95 *** a/src/backend/replication/logical/snapbuild.c --- b/src/backend/replication/logical/snapbuild.c *************** SnapBuildInitialSnapshot(SnapBuild *buil *** 619,624 **** --- 619,625 ---- =20=20 snap->xcnt =3D newxcnt; snap->xip =3D newxip; + snap->satisfies =3D HeapTupleSatisfiesMVCC; =20=20 return snap; } --=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