Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uXiXr-00DY00-2A for pgsql-general@arkaria.postgresql.org; Fri, 04 Jul 2025 15:41:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uXiXo-001cAu-Q5 for pgsql-general@arkaria.postgresql.org; Fri, 04 Jul 2025 15:41:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uXiXo-001cAj-Eu for pgsql-general@lists.postgresql.org; Fri, 04 Jul 2025 15:41:45 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uXiXn-005Z6R-0u for pgsql-general@lists.postgresql.org; Fri, 04 Jul 2025 15:41:44 +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 564FffXG250321; Fri, 4 Jul 2025 11:41:41 -0400 From: Tom Lane To: Erik Johnston cc: pgsql-general@lists.postgresql.org Subject: Re: Corrupt btree index includes rows that don't match In-reply-to: References: <01df0ca4-cf32-448f-a2cb-e44a8e9f7fd6@element.io> Comments: In-reply-to Erik Johnston message dated "Fri, 04 Jul 2025 15:59:55 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <250319.1751643701.1@sss.pgh.pa.us> Date: Fri, 04 Jul 2025 11:41:41 -0400 Message-ID: <250320.1751643701@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Erik Johnston writes: > We've also now found that the index on the backup does in fact point to > those ctids after all, but they are marked as dead. So at some point > between then and when we inserted the new row at that ctid today those > entries were marked undead. I wonder if this behavior could be related to this 14.18 fix: https://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=4934d3875 It probably isn't, because AFAICS that would only lead to transiently wrong answers --- but maybe you have a workload that occasionally hits that bug in the context of a query that will update and re-insert the recently-dead tuples? Still a bit far-fetched though, and if the index is actually corrupt this doesn't explain how it got that way. I'm more inclined to just say "once a btree index is out of order it can do some very strange things, both during inserts and searches". If you had some evidence about when and how the index became corrupt, it'd be worth studying that, but it sounds like you don't. regards, tom lane