Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bDbc8-0003Bt-N5 for pgsql-committers@arkaria.postgresql.org; Thu, 16 Jun 2016 18:02:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bDbc8-0003Si-9o for pgsql-committers@arkaria.postgresql.org; Thu, 16 Jun 2016 18:02:00 +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 1bDbbv-00032R-E4; Thu, 16 Jun 2016 18:01:47 +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 1bDbbs-0007vz-MY; Thu, 16 Jun 2016 18:01:46 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 6205220472; Thu, 16 Jun 2016 14:01:43 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute2.internal (MEProxy); Thu, 16 Jun 2016 14:01:43 -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=Nzj5unhcbUVY5pTsdPMi6zU4Sn0=; b=k3L7O fL5QMe3ROn5AKvl2BMRE4Jmy380Ix70KBaYeXua78MtIgX+EfKwAghkQZDmmQuEN 9gzDFGgsZWH8ofEjAMIIprj5xblRS4teEy8ma2cn+gdaDsIBmOvPhq6SlzY7HUN/ roBCzgrZla5yWEzvFWVqxMJyvCvCPz6rMI9y5g= X-Sasl-enc: VceRcd4iKFyYb4x7lg2IwriF7NineEjajjWMeI5xV0SF 1466100102 Received: from intern.anarazel.de (somacentral1.static.monkeybrains.net [162.217.75.74]) by mail.messagingengine.com (Postfix) with ESMTPA id E190DF29F3; Thu, 16 Jun 2016 14:01:42 -0400 (EDT) Date: Thu, 16 Jun 2016 11:01:41 -0700 From: Andres Freund To: Robert Haas Cc: Kevin Grittner , 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: <20160616180141.rnknufflldy7o5if@alap3.anarazel.de> References: <20160615223440.omhksf4senwtfc6q@alap3.anarazel.de> <20160616015730.rtozaq5mmlhci6xy@alap3.anarazel.de> <20160616153745.upxilwj3spbi43dj@alap3.anarazel.de> <20160616161426.bapgkbh762ktzyhk@alap3.anarazel.de> <20160616165440.pla4q3gbozyciuyo@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 13:44:34 -0400, Robert Haas wrote: > On Thu, Jun 16, 2016 at 12:54 PM, Andres Freund wrote: > >> The root of my confusion is: if we prune a tuple, we'll bump the page > >> LSN, so any session that is still referencing that tuple will error > >> out as soon as it touches the page on which that tuple used to exist. > > > > Right. On the main table. But we don't peform that check on the toast > > table/pages. So if we prune toast tuples, which are still referenced by > > (unvacuumed) main relation, we can get into trouble. > > OK, if it's true that we don't perform that check on the TOAST table, > then I agree there's a potential problem there. I don't immediately > know where in the code to look to check that. static inline void TestForOldSnapshot(Snapshot snapshot, Relation relation, Page page) { Assert(relation != NULL); if (old_snapshot_threshold >= 0 && (snapshot) != NULL && (snapshot)->satisfies == HeapTupleSatisfiesMVCC && !XLogRecPtrIsInvalid((snapshot)->lsn) && PageGetLSN(page) > (snapshot)->lsn) TestForOldSnapshot_impl(snapshot, relation); } The relevant part is the HeapTupleSatisfiesMVCC check, we're using SatisfiesToast for toast lookups. FWIW, I just tried to reproduce this with old_snapshot_threshold = 0 - but ran into the problem that I couldn't get it to vacuum anything away (neither main nor toast rel). That appears to be if (old_snapshot_threshold == 0) { if (TransactionIdPrecedes(latest_xmin, MyPgXact->xmin) && TransactionIdFollows(latest_xmin, xlimit)) xlimit = latest_xmin; because latest_xmin always is equal to MyPgXact->xmin, which is actually kinda unsurprising? Regards, Andres -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers