Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bDaZ8-0008Py-JR for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Jun 2016 16:54:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bDaZ8-0004Xq-5N for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Jun 2016 16:54:50 +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 1bDaZ6-0004VR-Bl; Thu, 16 Jun 2016 16:54:48 +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 1bDaZ2-0004Vr-HG; Thu, 16 Jun 2016 16:54:47 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 5B0E121F41; Thu, 16 Jun 2016 12:54:42 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute2.internal (MEProxy); Thu, 16 Jun 2016 12:54:42 -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=b+b1p7NrjEIyIOIoOOtUSjd+VG4=; b=QLFhz PipQi6xhugPgLJDSZg4ZifP543cA+L+FAjsCWfOd372KGPNjE4gfDctfvj3/JgUv 1wWupFVfabIujJLUUdi+kCyyzdqwjvPRYSEsO/AzLTkoTY1m3if+DHc5zPONYO3K 9CIYsc667L7l+AHJcnN7FfqiNewMlp+EnVqdnk= X-Sasl-enc: N3Okwi7k8pRki65ubWNE9Hvx72Jv6+Jf2XavvKtox15E 1466096081 Received: from intern.anarazel.de (unknown [192.77.237.104]) by mail.messagingengine.com (Postfix) with ESMTPA id CAF98CCD88; Thu, 16 Jun 2016 12:54:41 -0400 (EDT) Date: Thu, 16 Jun 2016 09:54:40 -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: Re: [COMMITTERS] pgsql: Avoid extra locks in GetSnapshotData if old_snapshot_threshold < Message-ID: <20160616165440.pla4q3gbozyciuyo@alap3.anarazel.de> References: <20160615202552.32oc3y3zzd5pukbp@alap3.anarazel.de> <20160615223440.omhksf4senwtfc6q@alap3.anarazel.de> <20160616015730.rtozaq5mmlhci6xy@alap3.anarazel.de> <20160616153745.upxilwj3spbi43dj@alap3.anarazel.de> <20160616161426.bapgkbh762ktzyhk@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-16 12:43:34 -0400, Robert Haas wrote: > On Thu, Jun 16, 2016 at 12:14 PM, Andres Freund wrote: > >> > 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. > >> > >> Is there really an assumption that the heap and the TOAST heap are > >> only ever vacuumed with the same OldestXmin value? Because that seems > >> like it would be massively flaky. > > > > There's not. They can be vacuumed days apart. But if we vacuum the toast > > table with an OldestXmin, and encounter a dead toast tuple, by the > > definition of OldestXmin (excluding STO), there cannot be a session > > reading the referencing tuple anymore - so that shouldn't matter. > > I don't understand how STO changes that. I'm not saying it doesn't > change it, but I don't understand why it would. Because we advance OldestXmin more aggressively, while allowing snapshots that are *older* than OldestXmin to access old tuples on pages which haven't been touched. > 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. > It won't even survive long enough to care that the tuple isn't there > any more. > > Maybe it would help if you lay out the whole sequence of events, like: > > S1: Does this. > S2: Does that. > S1: Now does something else. I presume it'd be something like: Assuming a 'toasted' table, which contains one row, with a 1GB field. S1: BEGIN REPEATABLE READ; S1: SELECT SUM(length(one_gb_record)) FROM toasted; S2: DELETE FROM toasted; AUTOVAC: vacuum toasted's toast table, it's large. skip toasted, it's small S1: SELECT SUM(length(one_gb_record)) FROM toasted; -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers