Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oic50-0006yG-Tf for pgsql-general@arkaria.postgresql.org; Wed, 12 Oct 2022 13:47:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oic4z-0007fx-Lu for pgsql-general@arkaria.postgresql.org; Wed, 12 Oct 2022 13:47:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oic4z-0007fJ-BK for pgsql-general@lists.postgresql.org; Wed, 12 Oct 2022 13:47:25 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oic4w-0006bl-Uw for pgsql-general@postgresql.org; Wed, 12 Oct 2022 13:47:24 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 29CDlEoh781475; Wed, 12 Oct 2022 09:47:15 -0400 From: Tom Lane To: Peter Geoghegan cc: Alvaro Herrera , Guillaume Lelarge , PostgreSQL General Subject: Re: Weird planner issue on a standby In-reply-to: References: <418848.1665505048@sss.pgh.pa.us> <20221011162736.cd2h5ajdbhtwdc4l@alvherre.pgsql> Comments: In-reply-to Peter Geoghegan message dated "Tue, 11 Oct 2022 23:14:47 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <781473.1665582434.1@sss.pgh.pa.us> Date: Wed, 12 Oct 2022 09:47:14 -0400 Message-ID: <781474.1665582434@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Geoghegan writes: > That's true, but it doesn't matter whether or not there are LP_DEAD > bits set on the standby, since in any case they cannot be trusted when > in Hot Standby mode. IndexScanDescData.ignore_killed_tuples will be > set to false on the standby. Hmm. I think that might break this argument in get_actual_variable_endpoint: * A crucial point here is that SnapshotNonVacuumable, with * GlobalVisTestFor(heapRel) as horizon, yields the inverse of the * condition that the indexscan will use to decide that index entries are * killable (see heap_hot_search_buffer()). Therefore, if the snapshot * rejects a tuple (or more precisely, all tuples of a HOT chain) and we * have to continue scanning past it, we know that the indexscan will mark * that index entry killed. That means that the next * get_actual_variable_endpoint() call will not have to re-consider that * index entry. In this way we avoid repetitive work when this function * is used a lot during planning. However, that doesn't explain the downthread report that a VACUUM on the primary fixed it. What I suspect is that that caused some in-fact-dead index entries to get cleaned out. But ... if the primary is allowed to vacuum away an index entry that it thinks is dead, exactly what is the point of making standbys ignore LP_DEAD bits? There's no additional interlock that guarantees the tuple will be there at all. regards, tom lane