Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bDc5O-0005Wp-SR for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Jun 2016 18:32:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bDc5O-0005g1-FR for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Jun 2016 18:32:14 +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 1bDc5N-0005eo-Od; Thu, 16 Jun 2016 18:32:13 +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 1bDc5K-0006ig-MW; Thu, 16 Jun 2016 18:32:13 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 7508520D3C; Thu, 16 Jun 2016 14:32:09 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute6.internal (MEProxy); Thu, 16 Jun 2016 14:32:09 -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=icYTpIfgeIL84pvbFy5wOnv4kzg=; b=CxZRu HnadlGSTbuvhy+cSZp9OaczZQDuOL5NEdsJouSG+tRSmzMlV0M8uf0skCxlQO3D6 a52astvjGvqxJCrM6nzvs2WD44FXz59Be9lPx/I6bqO42SgDe4x3sSApRde8H/F2 Ue17PZhQn6qKW7XsfnbShX12FvVgYMKOaLL45s= X-Sasl-enc: 0p/zDUrArUshIo/8p0FIo5pk5gfZQO/0kgk/U3V5nYUx 1466101929 Received: from intern.anarazel.de (somacentral1.static.monkeybrains.net [162.217.75.74]) by mail.messagingengine.com (Postfix) with ESMTPA id 1AAFCCCDA1; Thu, 16 Jun 2016 14:32:09 -0400 (EDT) Date: Thu, 16 Jun 2016 11:32:07 -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: Re: [COMMITTERS] pgsql: Avoid extra locks in GetSnapshotData if old_snapshot_threshold < Message-ID: <20160616183207.wygoktoplycdzav7@alap3.anarazel.de> References: <20160616015730.rtozaq5mmlhci6xy@alap3.anarazel.de> <20160616153745.upxilwj3spbi43dj@alap3.anarazel.de> <20160616161426.bapgkbh762ktzyhk@alap3.anarazel.de> <20160616165440.pla4q3gbozyciuyo@alap3.anarazel.de> <20160616180141.rnknufflldy7o5if@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 13:16:35 -0500, Kevin Grittner wrote: > On Thu, Jun 16, 2016 at 1:01 PM, Andres Freund wrote: > > > 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? > > Sure -- the STO feature *never* advances the point for early > pruning past the earliest still-active transaction ID. If it did > we would have all sorts of weird problems. Both latest_xmin, MyPgXact->xmin are equivalent to txid_current() here. Note that a threshold of 1 actually vacuums in this case (after waiting obviously), but 0 never does. Afaics that's because before TransactionIdLimitedForOldSnapshots() is reached, MaintainOldSnapshotTimeMapping will have updated latest_xmin to the current value. With old_snapshot_threshold=1 I indeed can reproduce the issue. I disabled autovacuum, to make the scheduling more predictable. But it should "work" just as well with autovacuum. S1: CREATE TABLE toasted(largecol text); INSERT INTO toasted SELECT string_agg(random()::text, '-') FROM generate_series(1, 10000000); BEGIN; DELETE FROM toasted; S2: BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ; S2: SELECT hashtext(largecol), length(largecol) FROM toasted; > ... S1: COMMIT; S2: SELECT hashtext(largecol), length(largecol) FROM toasted; > ... S1: /* wait for snapshot threshold to be passed */ S1: VACUUM pg_toast.pg_toast_16437; > INFO: 00000: "pg_toast_16437": found 61942 removable, 0 nonremovable row versions in 15486 out of 15486 pages > DETAIL: 0 dead row versions cannot be removed yet. S2: SELECT hashtext(largecol), length(largecol) FROM toasted; ERROR: XX000: missing chunk number 0 for toast value 16455 in pg_toast_16437 LOCATION: toast_fetch_datum, tuptoaster.c:1945 Andres -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers