Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFReQ-0007BI-SO for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Jun 2016 19:47:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bFReQ-0005pv-5M for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Jun 2016 19:47:58 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bFRd2-0002oJ-8K for pgsql-hackers@postgresql.org; Tue, 21 Jun 2016 19:46:32 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bFRcz-0002fV-8g for pgsql-hackers@postgresql.org; Tue, 21 Jun 2016 19:46:31 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 6E27520CD1; Tue, 21 Jun 2016 15:46:27 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute7.internal (MEProxy); Tue, 21 Jun 2016 15:46:27 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=0hGmKNYR0LUKMDx6vDGmx1CxiFw=; b=kHii/ 4p3Es+jkyD8NeCVbACuqBMzE7PJCUJg2wGl8u77XuQoxqXW7ncawLJcuWOPPDnn8 kJhQVarUy74WAxKNPEvmvJKuEzB0UAsH/Ov7KMlaN2iJa36atfzc6NNReHk+75SR MvN4roPKlOdtz+pG/DhV2fD6JBKGL+scLixc+Y= X-Sasl-enc: 2E+f7lfeR3bo21GheQljmVIYAsaScN1iTaXiIjE0vRiV 1466538387 Received: from intern.anarazel.de (somacentral1.static.monkeybrains.net [162.217.75.74]) by mail.messagingengine.com (Postfix) with ESMTPA id 15EC2CCDB7; Tue, 21 Jun 2016 15:46:27 -0400 (EDT) Date: Tue, 21 Jun 2016 12:46:26 -0700 From: Andres Freund To: Robert Haas Cc: Amit Kapila , Thomas Munro , Alvaro Herrera , Stephen Frost , Michael Paquier , Masahiko Sawada , "pgsql-hackers@postgresql.org" Subject: Re: Reviewing freeze map code Message-ID: <20160621194626.o7jfjjp4wfawgx46@alap3.anarazel.de> References: <20160620193302.s4dbul6japgar5eg@alap3.anarazel.de> <20160621035138.rwbbqcnaoqgnd5iv@alap3.anarazel.de> <20160621165415.2khpeffceio4gxs3@alap3.anarazel.de> <20160621174953.wmxqf5sxmo7lv2if@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 2016-06-21 15:38:25 -0400, Robert Haas wrote: > On Tue, Jun 21, 2016 at 1:49 PM, Andres Freund wrote: > >> I'm also a bit dubious that LockAcquire is safe to call in general > >> with interrupts held. > > > > Looks like we could just acquire the tuple-lock *before* doing the > > toast_insert_or_update/RelationGetBufferForTuple, but after releasing > > the buffer lock. That'd allow us to do avoid doing the nested locking, > > should make the recovery just a goto l2;, ... > > Why isn't that racey? Somebody else can grab the tuple lock after we > release the buffer content lock and before we acquire the tuple lock. Sure, but by the time the tuple lock is released, they'd have updated xmax. So once we acquired that we can just do if (xmax_infomask_changed(oldtup.t_data->t_infomask, infomask) || !TransactionIdEquals(HeapTupleHeaderGetRawXmax(oldtup.t_data), xwait)) goto l2; which is fine, because we've not yet done the toasting. I'm not sure wether this approach is better than deleting potentially toasted data though. It's probably faster, but will likely touch more places in the code, and eat up a infomask bit (infomask & HEAP_MOVED == HEAP_MOVED in my prototype). Andres -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers