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 1nLctt-0004O9-JC for pgsql-hackers@arkaria.postgresql.org; Sun, 20 Feb 2022 03:28:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nLcts-0004ER-EE for pgsql-hackers@arkaria.postgresql.org; Sun, 20 Feb 2022 03:28:40 +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 1nLcts-0004EI-4d for pgsql-hackers@lists.postgresql.org; Sun, 20 Feb 2022 03:28:40 +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 1nLctp-0007om-Ap for pgsql-hackers@lists.postgresql.org; Sun, 20 Feb 2022 03:28:39 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 186183200D53; Sat, 19 Feb 2022 22:28:35 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sat, 19 Feb 2022 22:28:35 -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=Wnoz0WVyImLui0xj7YxiIY38oVTHJjEEX8Dr09 HePHk=; b=n+OT9TXRzYwaJtAHPwMQ8B+hJNFW2+g5fboLhHXOA7a4IovS5GPfic RmjDNuF6Q8EPLG/kSDedSluohW27rXYftdP7pLZp5d60T9DVvMaVzK5SMn4JEmRr RbC6xXhgL9N4+PkwFwNsnF9fiW3S9Ans9r2vCiu6wjeUlgtDDJnkeG0xMd/4385b Ratar63Z9zH55/ao9daKu5O+6V4ReXtlzOZiUj9ZtV8FidtaF+sPLVYf8yM8+gZb rNrxYhlFnTOsn/4QjnH4bg+ku7qNJ/9J+4vDh/mtDUIT+NjHoqLs2jPiCwsncoEM KcrnWXN23H5sN0/E++KNRfy9AMmTq7OQ== 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=Wnoz0WVyImLui0xj7 YxiIY38oVTHJjEEX8Dr09HePHk=; b=bLSS+AjKpop2Jv8NREL9xGmNemYEOP5cO nbEqgqcb34myoQA+MCVb/xf+PisiPT7ImC3EPkfwuCD/VmJxG24owRT0GUe42Ps5 ATyMDd8l8BBi2BNHhq3XT4S0rToqBm7GvoM9cTdSRgLBy49cl0c76YY68zaoQsVR 3ev1LInvXHvC50HrsJawrbKnBr+s3rybSreMg03kLiMG1YSHJjaM3WiQGCeYX+t9 ZvZwhSkRQylg16iO+GwX9MxGwfqqZNVqH17VuDEunSL3E6Bs8Bp0CaRTwJBeNe6O VyLrPGcT4fWm4inhi9CxqD/DX98e2qmE47x0povOUKmCDVXQpOEyA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrkeefgdehlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnhepudekhfekleeugeevteehleffffejgeelueduleeffeeutdelffeujeffhfeu ffdunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 19 Feb 2022 22:28:34 -0500 (EST) Date: Sat, 19 Feb 2022 19:28:33 -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: <20220220032833.tvdxa3ddfuvu3ezu@alap3.anarazel.de> References: <20220218221117.ijozsjwaxa6fy5u6@alap3.anarazel.de> <20220220015416.gxnocs4we56ghmj3@alap3.anarazel.de> <20220220030128.sgytb3wccteb3opj@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 19:07:39 -0800, Peter Geoghegan wrote: > On Sat, Feb 19, 2022 at 7:01 PM Andres Freund wrote: > > > 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. > > No, it just isn't robust enough. But it's not that hard to fix. My > patch really wasn't invasive. I think we're in agreement there. We might think at some point about backpatching too, but I'd rather have it stew in HEAD for a bit first. > I confirmed that HeapTupleSatisfiesVacuum() and > heap_prune_satisfies_vacuum() agree that the heap-only tuple at offnum > 2 is HEAPTUPLE_DEAD -- they are in agreement, as expected (so no > reason to think that there is a new bug involved). The problem here is > indeed just that heap_prune_chain() can't "get to" the tuple, given > its current design. Right. The reason that the "adversarial" patch makes a different is solely that it changes the heap_surgery test to actually kill an item, which it doesn't intend: create temp table htab2(a int); insert into htab2 values (100); update htab2 set a = 200; vacuum htab2; -- redirected TIDs should be skipped select heap_force_kill('htab2'::regclass, ARRAY['(0, 1)']::tid[]); If the vacuum can get the cleanup lock due to the adversarial patch, the heap_force_kill() doesn't do anything, because the first item is a redirect. However if it *can't* get a cleanup lock, heap_force_kill() instead targets the root item. Triggering the endless loop. Hm. I think this might be a mild regression in 14. In < 14 we'd just skip the tuple in lazy_scan_heap(), but now we have an uninterruptible endless loop. We'd do completely bogus stuff later in < 14 though, I think we'd just leave it in place despite being older than relfrozenxid, which obviously has its own set of issues. Greetings, Andres Freund