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 1lVedJ-0005Jl-9e for pgsql-hackers@arkaria.postgresql.org; Sun, 11 Apr 2021 18:16:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lVedH-0005cm-T9 for pgsql-hackers@arkaria.postgresql.org; Sun, 11 Apr 2021 18:16:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lVedH-0005cf-MT for pgsql-hackers@lists.postgresql.org; Sun, 11 Apr 2021 18:16:27 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lVedE-0001TF-Sn for pgsql-hackers@lists.postgresql.org; Sun, 11 Apr 2021 18:16:26 +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 13BIGJ1H2692615; Sun, 11 Apr 2021 14:16:20 -0400 From: Tom Lane To: Peter Geoghegan cc: Andres Freund , PostgreSQL Hackers Subject: Re: PANIC: wrong buffer passed to visibilitymap_clear In-reply-to: References: <2247102.1618008027@sss.pgh.pa.us> <20210409232739.sazp5p4xnnagrusa@alap3.anarazel.de> <20210409233203.3khg3s5iw34g4xrc@alap3.anarazel.de> <2644575.1618117467@sss.pgh.pa.us> <2679216.1618156670@sss.pgh.pa.us> <2689873.1618161194@sss.pgh.pa.us> <2691106.1618162892@sss.pgh.pa.us> <2691724.1618163730@sss.pgh.pa.us> Comments: In-reply-to Peter Geoghegan message dated "Sun, 11 Apr 2021 11:07:33 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2692612.1618164979.1@sss.pgh.pa.us> Date: Sun, 11 Apr 2021 14:16:19 -0400 Message-ID: <2692613.1618164979@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Geoghegan writes: > On Sun, Apr 11, 2021 at 10:55 AM Tom Lane wrote: >> Either way, it's hard to argue that >> heap_update hasn't crossed the complexity threshold where it's >> impossible to maintain safely. We need to simplify it. > It is way too complicated. I don't think that I quite understand your > first proposal right now, so I'll need to go think about it. It wasn't very clear, because I hadn't thought it through very much; but what I'm imagining is that we discard most of the thrashing around all-visible rechecks and have just one such test somewhere very late in heap_update, after we've successfully acquired a target buffer for the update and are no longer going to possibly need to release any buffer lock. If at that one point we see the page is all-visible and we don't have the vmbuffer, then we have to release all our locks and go back to "l2". Which is less efficient than some of the existing code paths, but given how hard this problem is to reproduce, it seems clear that optimizing for the occurrence is just not worth it. regards, tom lane