Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bDZMf-0004yl-Sf for pgsql-committers@arkaria.postgresql.org; Thu, 16 Jun 2016 15:37:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bDZMf-0003h6-BU for pgsql-committers@arkaria.postgresql.org; Thu, 16 Jun 2016 15:37:53 +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 1bDZMd-0003eE-TA; Thu, 16 Jun 2016 15:37:51 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bDZMa-0002o3-DW; Thu, 16 Jun 2016 15:37:51 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id B8D992086C; Thu, 16 Jun 2016 11:37:46 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute2.internal (MEProxy); Thu, 16 Jun 2016 11:37:46 -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=T4TwCDbrFY2BxT6MNvui1RkiN0c=; b=krf2y WFhYbcpkMGN/9g7gT9DKrRUdn6Di7ItpRBuDpZEdUzPK/Cve3PCf4aiuj6eu/FeV X31xCzsB6ZEKASByAmhBxVZJGbkzDGSHHTXjy1q30PvFvH1knWbI0Nuu/IR/c0Re 1916xbOsrq7HP49XRIr3wg/tZJUqD4pkJHf48s= X-Sasl-enc: uBmryCTI17SfUL7Q4tXH8C360KfbsjxoIriZmjIuP6Gu 1466091466 Received: from intern.anarazel.de (unknown [192.77.237.104]) by mail.messagingengine.com (Postfix) with ESMTPA id 3FFDDCCDB8; Thu, 16 Jun 2016 11:37:46 -0400 (EDT) Date: Thu, 16 Jun 2016 08:37:45 -0700 From: Andres Freund To: Kevin Grittner Cc: Robert Haas , Alvaro Herrera , Ants Aasma , Amit Kapila , Noah Misch , Kevin Grittner , "pgsql-hackers@postgresql.org" , "pgsql-committers@postgresql.org" Subject: Re: [HACKERS] Re: pgsql: Avoid extra locks in GetSnapshotData if old_snapshot_threshold < Message-ID: <20160616153745.upxilwj3spbi43dj@alap3.anarazel.de> References: <20160615184537.GA20738@alvherre.pgsql> <20160615192011.eicg7hwkndyx2cmo@alap3.anarazel.de> <20160615202552.32oc3y3zzd5pukbp@alap3.anarazel.de> <20160615223440.omhksf4senwtfc6q@alap3.anarazel.de> <20160616015730.rtozaq5mmlhci6xy@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-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org On 2016-06-16 09:50:09 -0500, Kevin Grittner wrote: > On Wed, Jun 15, 2016 at 8:57 PM, Andres Freund wrote: > > > The simplest version of the scenario I'm concerned about is that a tuple > > in a tuple is *not* vacuumed, even though it's elegible to be removed > > due to STO. If that tuple has toasted columns, it could be the that the > > toast table was independently vacuumed (autovac considers main/toast > > tables separately, > > If that were really true, why would we not have the problem in > current production versions that the toast table could be vacuumed > before the heap, leading to exactly the issue you are talking > about? The issue isn't there without the feature, because we (should) never access a tuple/detoast a column when it's invisible enough for the corresponding toast tuple to be vacuumed away. But with old_snapshot_timeout that's obviously (intentionally) not the case anymore. Due to old_snapshot_threshold we'll prune tuples which, without it, would still be considered HEAPTUPLE_RECENTLY_DEAD. > It seems to me that a simple test shows that it is not the > case that the heap is vacuumed without considering toast: That's why I mentioned autovacuum: /* * Scan pg_class to determine which tables to vacuum. * * We do this in two passes: on the first one we collect the list of plain * relations and materialized views, and on the second one we collect * TOAST tables. The reason for doing the second pass is that during it we * want to use the main relation's pg_class.reloptions entry if the TOAST * table does not have any, and we cannot obtain it unless we know * beforehand what's the main table OID. * * We need to check TOAST tables separately because in cases with short, * wide tables there might be proportionally much more activity in the * TOAST table than in its parent. */ ... tab->at_vacoptions = VACOPT_SKIPTOAST | (dovacuum ? VACOPT_VACUUM : 0) | (doanalyze ? VACOPT_ANALYZE : 0) | (!wraparound ? VACOPT_NOWAIT : 0); (note the skiptoast) ... /* * Remember the relation's TOAST relation for later, if the caller asked * us to process it. In VACUUM FULL, though, the toast table is * automatically rebuilt by cluster_rel so we shouldn't recurse to it. */ if (!(options & VACOPT_SKIPTOAST) && !(options & VACOPT_FULL)) toast_relid = onerel->rd_rel->reltoastrelid; else toast_relid = InvalidOid; ... if (toast_relid != InvalidOid) vacuum_rel(toast_relid, relation, options, params); > > or the horizon could change between the two heap scans, > > Not a problem in current production why? Because the horizon will never go to a value which allows "surely dead" tuples to be read, thus we never detoast columns from a tuple for which we'd removed toast data. That's why we're performing visibility tests (hopefully) everywhere, before accessing tuple contents (as opposed to inspecting the header). > > or pins could prevent vacuuming of one page, or ...). > > Not a problem in current production why? Same reason. > So far I am not seeing any way for TOAST tuples to be pruned in > advance of the referencing heap tuples, nor any way for the problem > you describe to happen in the absence of that. Didn't I just list three different ways, only one of which you doubted the veracity of? Saying "Not a problem in current production why" doesn't change it being a problem. > > It seems the easiest way to fix this would be to make > > TestForOldSnapshot() "accept" SnapshotToast as well. > > I don't think that would be appropriate without testing the > characteristics of the underlying table to see whether it should be > excluded. You mean checking whether it's a toast table? We could check that, but since we never use a toast scan outside of toast, it doesn't seem necessary. > But is the TOAST data ever updated without an update to > the referencing heap tuple? It shouldn't. > If not, I don't see any benefit. Huh? Greetings, Andres Freund -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers