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 1nLcTu-0003AA-0t for pgsql-hackers@arkaria.postgresql.org; Sun, 20 Feb 2022 03:01:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nLcTr-0001eC-6I for pgsql-hackers@arkaria.postgresql.org; Sun, 20 Feb 2022 03:01:47 +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 1nLcTp-0001e3-6r for pgsql-hackers@lists.postgresql.org; Sun, 20 Feb 2022 03:01:46 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nLcTf-0007dz-BO for pgsql-hackers@lists.postgresql.org; Sun, 20 Feb 2022 03:01:44 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 03FB532007F9; Sat, 19 Feb 2022 22:01:30 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sat, 19 Feb 2022 22:01:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; bh=fuu3QHMEHuMZcs1WixE9OKzMpPe5u5uYyOO9KD QFtl8=; b=ZgSSWjgH3iYF9m3cNBRGhST78wYqQe5FErlcWtG6bKzob3eEZtJN64 OUl00NZZDpMn4jxNG1Wo6SDYnYKotqciXnqUPnWp2n6c7iNKMeCNCU4CRgCTLpjT FIgcKpH0dj2OMYv9OKWOLEOaBc6RuH5Ieh/giZ/tmmX/uBfvf5M4Jpe283Hio3O1 Ro3Oj95DwSkOwBkr1kBS0UQ/efR00WjuIm2jYm/QwIdDFOu83voPSYBHS8ZGviGs rjCldE+y4iN++ed+RlMkY8WL6BaCjQEKgCHfx0bJONYZ01cXKCl+s4fPbno6RAIJ r2J2PjMs6LeWdF0TQqjyuPVNnS1rNhTg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=fuu3QHMEHuMZcs1Wi xE9OKzMpPe5u5uYyOO9KDQFtl8=; b=Vv64uXRmS+daAt5fQke2dC2ocpyY6GGbu C1Tt9a21S4rBRt4lj/NeGOp1uArPX4qp6jZGPO+ZjMBgUBA5Tpq4hboP4kYebicN BhbATJ+twsdKyMi4isqQPEQQLa9V5nfXNa4Cmo/wnhF+GqsvVU+SGRbLa28yP+0B r/75rs7soJ8PzJpSzieJ+N+m7hFNeLUaXhVyTBZ8bKFoci17L0KayYjic5q0TpO/ 9QoJuKSwxKSFE3VmmpdLoCwfl6TMwRmEZIHFdZC/0K3tpDKCDKBE8ZThjoPm3rmE G22SJBLqA4BDjlnH9RAiP1LMpnnENxD7Psr8FcJd84uCNMgdi1orA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrkeefgdehfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnhepudekhfekleeugeevteehleffffejgeelueduleeffeeutdelffeujeffhfeu ffdunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 19 Feb 2022 22:01:29 -0500 (EST) Date: Sat, 19 Feb 2022 19:01:28 -0800 From: Andres Freund To: Peter Geoghegan Cc: Robert Haas , Masahiko Sawada , PostgreSQL Hackers Subject: Re: Removing more vacuumlazy.c special cases, relfrozenxid optimizations Message-ID: <20220220030128.sgytb3wccteb3opj@alap3.anarazel.de> References: <20220218221117.ijozsjwaxa6fy5u6@alap3.anarazel.de> <20220220015416.gxnocs4we56ghmj3@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2022-02-19 18:16:54 -0800, Peter Geoghegan wrote: > On Sat, Feb 19, 2022 at 5:54 PM Andres Freund wrote: > > How does that cause the endless loop? > > Attached is the page image itself, dumped via gdb (and gzip'd). This > was on recent HEAD (commit 8f388f6f, actually), plus > 0001-Add-adversarial-ConditionalLockBuff[...]. No other changes. No > defragmenting in pg_surgery, nothing like that. > > It doesn't do so on HEAD + 0001-Add-adversarial-ConditionalLockBuff[...] for > > me. So something needs have changed with your patch? > > It doesn't always happen -- only about half the time on my machine. > Maybe it's timing sensitive? Ah, I'd only run the tests three times or so, without it happening. Trying a few more times repro'd it. It's kind of surprising that this needs this 0001-Add-adversarial-ConditionalLockBuff to break. I suspect it's a question of hint bits changing due to lazy_scan_noprune(), which then makes HeapTupleHeaderIsHotUpdated() have a different return value, preventing the "If the tuple is DEAD and doesn't chain to anything else" path from being taken. > We hit the "goto retry" on offnum 2, which is the first tuple with > storage (you can see "the ghost" of the tuple from the LP_DEAD item at > offnum 1, since the page isn't defragmented in pg_surgery). I think > that this happens because the heap-only tuple at offnum 2 is fully > DEAD to lazy_scan_prune, but hasn't been recognized as such by > heap_page_prune. There is no way that they'll ever "agree" on the > tuple being DEAD right now, because pruning still doesn't assume that > an orphaned heap-only tuple is fully DEAD. > We can either do that, or we can throw an error concerning corruption > when heap_page_prune notices orphaned tuples. Neither seems > particularly appealing. But it definitely makes no sense to allow > lazy_scan_prune to spin in a futile attempt to reach agreement with > heap_page_prune about a DEAD tuple really being DEAD. Yea, this sucks. I think we should go for the rewrite of the heap_prune_chain() logic. The current approach is just never going to be robust. Greetings, Andres Freund