Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eAdLq-0005NA-3g for pgsql-committers@arkaria.postgresql.org; Fri, 03 Nov 2017 14:53:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1eAdLp-0002R7-MZ for pgsql-committers@arkaria.postgresql.org; Fri, 03 Nov 2017 14:53:41 +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 1eAdLn-0002LK-Qh; Fri, 03 Nov 2017 14:53:40 +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.84_2) (envelope-from ) id 1eAdLj-0008R6-Jz; Fri, 03 Nov 2017 14:53:39 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 4E79621053; Fri, 3 Nov 2017 10:53:33 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute5.internal (MEProxy); Fri, 03 Nov 2017 10:53:33 -0400 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=/8HUmCGYxmrZEjbWOgdL8J3zLxJp+ gMAHxJUJlIMx3M=; b=b1OLaWx4Tduggwnjpr2whSAKsvRh/q/jry8xCd1AFrGbC A1OYrziNJMpxCTIXvhoNPENEukKRLhWdUUT0xNotfyT8665zSftGEu/jbRLJsvu0 G7AOovCy5cngr9iS637mggWKVg0euxRpOkhVniga1AWlsji9gpJcgT7dMz3Gx8M+ YmpKNo3NX80iiRnzO26J/djD9CU/jIPGm7aTwMRf5qZoVZWlRrOVi1igtLbRF8l7 D6sEsKkOjPsbXm9KroNbtQCtkqEpyGyCQ2zHvr15KlSdgrcNuSL5MirgpKOei2ka ndhQjo89A7O4EuLiy32gdbzrKbFRcRADmcgSP3qWA== X-ME-Sender: Received: from intern.anarazel.de (unknown [114.143.230.4]) by mail.messagingengine.com (Postfix) with ESMTPA id 9D5B82486C; Fri, 3 Nov 2017 10:53:32 -0400 (EDT) Date: Fri, 3 Nov 2017 07:53:30 -0700 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] pgsql: Fix freezing of a dead HOT-updated tuple Message-ID: <20171103145330.5ycjoje5s6lfwxps@alap3.anarazel.de> References: <20171102112019.33wb7g5wp4zpjelu@alap3.anarazel.de> <20171102124947.hshl7znx6ixy62pf@alvherre.pgsql> <20171102130551.i2w33sqdw3bdvetn@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nazui2mdok3gijop" Content-Disposition: inline In-Reply-To: <20171102130551.i2w33sqdw3bdvetn@alap3.anarazel.de> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org --nazui2mdok3gijop Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On 2017-11-02 06:05:51 -0700, Andres Freund wrote: > Hi, > > On 2017-11-02 13:49:47 +0100, Alvaro Herrera wrote: > > Andres Freund wrote: > > > I think the problem is on the pruning, rather than the freezing side. We > > > can't freeze a tuple if it has an alive predecessor - rather than > > > weakining this, we should be fixing the pruning to not have the alive > > > predecessor. > > > > I gave a look at HTSV back then, but I didn't find what the right tweak > > was, but then I only tried changing the return value to DEAD and > > DELETE_IN_PROGRESS; the thought of selecting DEAD or RECENTLY_DEAD based > > on OldestXmin didn't occur to me ... I was thinking that the fact that > > there were live lockers meant that the tuple could not be removed, > > obviously failing to notice that the subsequent versions of the tuple > > would be good enough. > > I'll try to write up a commit based on that idea. I think there's some > comment work needed too, Robert and I were both confused by a few > things. > I'm unfortunately travelling atm - it's evening here, and I'll flying > back to the US all Saturday. I'm fairly sure I'll be able to come up > with a decent patch tomorrow, but I'll need review and testing by > others. 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. 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? Greetings, Andres Freund --nazui2mdok3gijop Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Fix-pruning-of-locked-and-updated-tuples.patch"