Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eERW0-000173-En for pgsql-committers@arkaria.postgresql.org; Tue, 14 Nov 2017 03:03:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eERVz-0004Wm-K7 for pgsql-committers@arkaria.postgresql.org; Tue, 14 Nov 2017 03:03:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eERVz-0004WY-7O; Tue, 14 Nov 2017 03:03:55 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eERVq-0002OQ-Bc; Tue, 14 Nov 2017 03:03:54 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 2BD66211E5; Mon, 13 Nov 2017 22:03:43 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute5.internal (MEProxy); Mon, 13 Nov 2017 22:03:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=YAhGJ4zbFLWwljuN6Ujsvm/KRqSBe fDwY7b9taX08oI=; b=MmVOMV5/UKJZIqudqRvVYXi0ovRfWsctNZFUVrteARt0C NcJv+Z67D3Rk2ANo9NroJ+mxYs18T/la26Zc0LzOfR9K5P+5YlxR4IBgJEMkkDxz 0S/guKujzFvgpRky3pWyPhs+GCVyeZuUMbq0VpIDhXDuSNrivK6dHQB3lngUbUQm xFzczM9R0daeyu0JZg2MpX1KxsCoXOKYyagZTMlsdj/NavJ63681gbxcRCRvWr8b tujQhcvgJ/EQbzqmdtzgPo20eKYPlADPxrjzu7zNJhuaMlkZvP8yTvLlbUzb+8xi PSLrHTQc5Su6+T0lggZeDl6yPGIBM/m9vlICQ+LTA== X-ME-Sender: Received: from intern.anarazel.de (unknown [136.24.76.189]) by mail.messagingengine.com (Postfix) with ESMTPA id B33E4240B2; Mon, 13 Nov 2017 22:03:42 -0500 (EST) Date: Mon, 13 Nov 2017 19:03:41 -0800 From: Andres Freund To: Alvaro Herrera Cc: "Wood, Dan" , Peter Geoghegan , pgsql-committers@postgresql.org, "Wong, Yi Wen" , Michael Paquier , Robert Haas , Tom Lane , pgsql-hackers@postgresql.org Subject: Re: [HACKERS] [COMMITTERS] pgsql: Fix freezing of a dead HOT-updated tuple Message-ID: <20171114030341.movhteyakqeqx5pm@alap3.anarazel.de> References: <20171102112019.33wb7g5wp4zpjelu@alap3.anarazel.de> <20171102124947.hshl7znx6ixy62pf@alvherre.pgsql> <20171102130551.i2w33sqdw3bdvetn@alap3.anarazel.de> <20171103145330.5ycjoje5s6lfwxps@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="v5vdn2gjqdtczff3" Content-Disposition: inline In-Reply-To: <20171103145330.5ycjoje5s6lfwxps@alap3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --v5vdn2gjqdtczff3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, On 2017-11-03 07:53:30 -0700, Andres Freund wrote: > Here's that patch. I've stared at this some, and Robert did too. Robert > mentioned that the commit message might need some polish and I'm not > 100% sure about the error message texts yet. > > I'm not yet convinced that the new elog in vacuumlazy can never trigger > - but I also don't think we want to actually freeze the tuple in that > case. I'm fairly sure it could be triggered, therefore I've rewritten that. I've played around quite some with the attached patch. So far, after applying the second patch, neither VACUUM nor VACUUM FULL / CLUSTER make the situation worse for already existing corruption. HOT pruning can change the exact appearance of existing corruption a bit, but I don't think it can make the corruption meaningfully worse. It's a bit annoying and scary to add so many checks to backbranches but it kinda seems required. The error message texts aren't perfect, but these are "should never be hit" type elog()s so I'm not too worried about that. Please review! One thing I'm wondering about is whether we have any way for users to diagnose whether they need to dump & restore - I can't really think of anything actually meaningful. Reindexing will find some instances, but far from all. VACUUM (disable_page_skipping, freeze) pg_class will also find a bunch. Not a perfect story. > Staring at the vacuumlazy hunk I think I might have found a related bug: > heap_update_tuple() just copies the old xmax to the new tuple's xmax if > a multixact and still running. It does so without verifying liveliness > of members. Isn't that buggy? Consider what happens if we have three > blocks: 1 has free space, two is being vacuumed and is locked, three is > full and has a tuple that's key share locked by a live tuple and is > updated by a dead xmax from before the xmin horizon. In that case afaict > the multi will be copied from the third page to the first one. Which is > quite bad, because vacuum already processed it, and we'll set > relfrozenxid accordingly. I hope I'm missing something here? Trying to write a testcase for that now. Greetings, Andres Freund --v5vdn2gjqdtczff3 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Fix-pruning-of-locked-and-updated-tuples.patch"