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 1ndx2B-0007o7-2q for pgsql-bugs@arkaria.postgresql.org; Mon, 11 Apr 2022 16:36:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ndx1B-0007cK-Qr for pgsql-bugs@arkaria.postgresql.org; Mon, 11 Apr 2022 16:35:57 +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 1ndx1B-0007cA-If for pgsql-bugs@lists.postgresql.org; Mon, 11 Apr 2022 16:35:57 +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 1ndx19-0003HI-5W for pgsql-bugs@lists.postgresql.org; Mon, 11 Apr 2022 16:35:56 +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 23BGZqw8290413; Mon, 11 Apr 2022 12:35:52 -0400 From: Tom Lane To: Peter Geoghegan cc: anisimow.d@gmail.com, PostgreSQL mailing lists Subject: Re: BUG #17462: Invalid memory access in heapam_tuple_lock In-reply-to: References: <17462-9c98a0f00df9bd36@postgresql.org> <286748.1649692519@sss.pgh.pa.us> Comments: In-reply-to Peter Geoghegan message dated "Mon, 11 Apr 2022 09:25:48 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <290411.1649694952.1@sss.pgh.pa.us> Date: Mon, 11 Apr 2022 12:35:52 -0400 Message-ID: <290412.1649694952@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Geoghegan writes: > On Mon, Apr 11, 2022 at 8:55 AM Tom Lane wrote: >> In principle, this is showing an actual bug, because once we drop >> the buffer pin somebody could replace the page before we get done >> examining the tuple. I'm not sure what the odds are of that happening >> in the field, but they're probably mighty low because a just-accessed >> buffer should not be high priority for replacement. > I imagine that the greater risk comes from concurrent opportunistic > pruning. Good point. I'm afraid that means we need a back-branch fix, which I guess requires an alternate entry point. > The other backend's page defragmentation step (from pruning) > would render our backend's HeapTuple pointer invalid. Presumably it > would just look like an invalid/non-matching xmin in our backend, at > the point of control flow that Valgrind complains about > (heapam_handler.c:509). Right, but there are other accesses below, and in any case match failure isn't necessarily the right thing. What that code is trying to do is chain up to the latest version of the tuple, and the likely end result would be to incorrectly conclude that there isn't one, resulting in failure to update a tuple that should have been updated. regards, tom lane