Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bDcUS-00073Z-OG for pgsql-committers@arkaria.postgresql.org; Thu, 16 Jun 2016 18:58:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bDcUS-0004uG-Ax for pgsql-committers@arkaria.postgresql.org; Thu, 16 Jun 2016 18:58:08 +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 1bDcUE-0004DE-Rz; Thu, 16 Jun 2016 18:57:54 +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 1bDcUB-0007IU-3n; Thu, 16 Jun 2016 18:57:54 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id CB54820973; Thu, 16 Jun 2016 14:57:49 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute2.internal (MEProxy); Thu, 16 Jun 2016 14:57:49 -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=sgrm4xWeUyqMA02ZdAnb8mYWpMw=; b=oAcQq pBX3j5vqwKuguV/ce9dgdHBa/9so/p3lE0zLyN3QazO1CVWwSuV3wIyjv6j8JeEk nptPMiKOLIWWTK+fQ0GNfH7czAbmRpgcwJooHcXhT8fBUvRKPjFnF2aYE5c5enYd VjZ/tcm7gtohmxG9dK35oKmjc68IaEmQumgEGE= X-Sasl-enc: xXcBAk2nTs7LA6hNw378ug6bLdV5dwGjdN5nU/L9HDwz 1466103469 Received: from intern.anarazel.de (somacentral1.static.monkeybrains.net [162.217.75.74]) by mail.messagingengine.com (Postfix) with ESMTPA id 6A40DCCDA7; Thu, 16 Jun 2016 14:57:49 -0400 (EDT) Date: Thu, 16 Jun 2016 11:57:48 -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: <20160616185748.32pjujl37xfo7rh7@alap3.anarazel.de> References: <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:53:01 -0500, Kevin Grittner wrote: > On Thu, Jun 16, 2016 at 1:19 PM, Kevin Grittner wrote: > > On Thu, Jun 16, 2016 at 11:54 AM, Andres Freund wrote: > >> On 2016-06-16 12:43:34 -0400, Robert Haas wrote: > > >>> 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; > >> > > > > I'll put together a test like that and post in a bit. > > old_snapshot_threshold = '1min' > autovacuum_vacuum_threshold = 0\ > autovacuum_vacuum_scale_factor = 0.0000000001 > > test=# CREATE TABLE gb (rec bytea not null); > CREATE TABLE > test=# ALTER TABLE gb ALTER COLUMN rec SET STORAGE external; > ALTER TABLE > test=# INSERT INTO gb SELECT t FROM (SELECT repeat('x', > 1000000000)::bytea) x(t); > INSERT 0 1 > test=# BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ; > BEGIN > test=# SELECT SUM(length(rec)) FROM gb; > sum > ------------ > 1000000000 > (1 row) > > [wait for autovacuum to run] > > test=# SELECT SUM(length(rec)) FROM gb; > ERROR: snapshot too old See https://www.postgresql.org/message-id/20160616183207.wygoktoplycdzav7@alap3.anar for a recipe that reproduce the issue. I presume your example also vacuums the main table due to the threshold and scale factor you set (which will pretty much alwasy vacuum a table, no?). 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