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 1hlJA9-0002na-Uo for pgsql-bugs@arkaria.postgresql.org; Wed, 10 Jul 2019 20:26:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hlJA8-0002WQ-QS for pgsql-bugs@arkaria.postgresql.org; Wed, 10 Jul 2019 20:26:00 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hlJA8-0002WI-Fi for pgsql-bugs@lists.postgresql.org; Wed, 10 Jul 2019 20:26:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hlJA6-0007BY-2j for pgsql-bugs@lists.postgresql.org; Wed, 10 Jul 2019 20:25:59 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x6AKPnju013552; Wed, 10 Jul 2019 16:25:49 -0400 From: Tom Lane To: Andres Freund cc: Peter Geoghegan , Manuel Rigger , PostgreSQL mailing lists Subject: Re: ERROR: found unexpected null value in index In-reply-to: <20190710201547.l6vs6y3cf2tuac73@alap3.anarazel.de> References: <9288.1562720919@sss.pgh.pa.us> <20825.1562723034@sss.pgh.pa.us> <8251.1562726821@sss.pgh.pa.us> <12489.1562788970@sss.pgh.pa.us> <20190710201547.l6vs6y3cf2tuac73@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Wed, 10 Jul 2019 13:15:47 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <13549.1562790349.1@sss.pgh.pa.us> Date: Wed, 10 Jul 2019 16:25:49 -0400 Message-ID: <13550.1562790349@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2019-07-10 16:02:50 -0400, Tom Lane wrote: >> Should we try to transpose some of this logic to below the AM API, >> and if so, what should that look like? > I wonder if we could push this down into a separate type of visibility > (or maybe redefine NonVacuumable)? So that the scan wouldn't ever > return them in the first place? It's a bit annoying to have a visibility > type that's perhaps best called "what selfuncs.c needs", but still seams > cleaner than having a separate callback? And the explanation for why > that's possibly needed also seems to better belong inside the AMs. SnapshotNonVacuumable is already basically "what selfuncs.c needs" --- nothing else is using it. So I wouldn't hesitate to redefine it if that'd fix the problem. But it doesn't sound like a promising approach. The problem here isn't whether the heap tuple is live or dead, it's whether it can be trusted to match the index entry. Also, snapshot checking isn't really below the AM API anyway is it? I wonder if we'd be better off to switch over to using data directly from the index entry, rather than trying to recover it from the heap. We'd then need to make sure that the logic exploits btree's "killed index entry" ability, so that dead extremal values are ignored as much as possible. But that'd get us out of the broken-HOT-chain problem. regards, tom lane