Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8UQ6-000371-2e for pgsql-bugs@arkaria.postgresql.org; Wed, 10 May 2017 16:24:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d8UQ5-00037a-KG for pgsql-bugs@arkaria.postgresql.org; Wed, 10 May 2017 16:24:57 +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 1d8UQ4-00035y-Gx; Wed, 10 May 2017 16:24:56 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d8UQ1-00022n-O0; Wed, 10 May 2017 16:24:55 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 66F44209B7; Wed, 10 May 2017 12:24:52 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute5.internal (MEProxy); Wed, 10 May 2017 12:24:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=mlqmOa0KkGPnmgRGqs 3CyW1vVQe4XJPom04blNV1cfc=; b=BH+pwfR2lGlAsfV8DRVPlDZKan3EnUYV6X evDktW7N4arOs66VGRcF+BFWrgX/dYG9avjaUGOJEvgJyLNHynvY0dYPOAnR9/SW zQQPBZlWHK6o4nqJB8GAjqox5Pw+1zrpPzSP2z0Iui8HSLz3Epxx1mky4xw0ReJc ukAj3cFbgane/iyEnFHEAgoeHjS0eOMiBEz/lYefXjJ3s5fKPCg1hmw7WSdDYd+Y mhysRV3CIJUa0e27Ko04Leyk+SaDB+blArXG+ndhXs31Uwyo8ob1hMUeWeajpJld TJP4KXY1VfPwk5nd8Qou3+HBnar/Y3WID2AtpEKnIKeOFHz9KX1Q== X-ME-Sender: X-Sasl-enc: OjU5j4dt+hcYthfSvGg9KWPFT3ygC00I3Tp9KeCfoa34 1494433492 Received: from intern.anarazel.de (unknown [136.24.76.72]) by mail.messagingengine.com (Postfix) with ESMTPA id 2DC9B24996; Wed, 10 May 2017 12:24:52 -0400 (EDT) Date: Wed, 10 May 2017 09:24:50 -0700 From: Andres Freund To: Tom Lane Cc: Petr Jelinek , Peter Eisentraut , pgsql-hackers@postgresql.org, Noah Misch , Jason Petersen , Michael Paquier , PostgreSQL mailing lists Subject: Re: Concurrent ALTER SEQUENCE RESTART Regression Message-ID: <20170510162450.bzfktkeexezepf6c@alap3.anarazel.de> References: <20170427062304.gxh3rczhh6vblrwh@alap3.anarazel.de> <20170430080517.GA811193@rfd.leadboat.com> <59aeb834-b113-6769-bfe4-65f2f8c875e3@2ndquadrant.com> <20170507234334.yimkp6aq2o43wtt2@alap3.anarazel.de> <4521f870-bb1f-1b29-3b3f-42419696efe7@2ndquadrant.com> <20d59e42-4a08-fa34-29df-9f54b3ef5ba7@2ndquadrant.com> <2913.1494426542@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2913.1494426542@sss.pgh.pa.us> X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 2017-05-10 10:29:02 -0400, Tom Lane wrote: > Petr Jelinek writes: > > On 10/05/17 07:09, Peter Eisentraut wrote: > >> I think the correct fix is to have nextval() and ALTER SEQUENCE use > >> sensible lock levels so that they block each other. Since > >> nextval() currently uses AccessShareLock, the suggestion was for > >> ALTER SEQUENCE to therefore use AccessExclusiveLock. But I think a > >> better idea would be for nextval() to use RowExclusiveLock > >> (analogous to UPDATE) and ALTER SEQUENCE to use > >> ShareRowExclusiveLock, which would also satisfy issue #1. > > > When I proposed this upstream, Andres raised concern about performance > > of nextval() if we do this, did you try to run any benchmark on this? > > As long as it doesn't block, the change in lock strength doesn't actually > make any speed difference does it? The issue isn't the strength, but that we currently have this weird hackery around open_share_lock(): /* * Open the sequence and acquire AccessShareLock if needed * * If we haven't touched the sequence already in this transaction, * we need to acquire AccessShareLock. We arrange for the lock to * be owned by the top transaction, so that we don't need to do it * more than once per xact. */ This'd probably need to be removed, as we'd otherwise would get very weird semantics around aborted subxacts. Upthread I theorized whether that's actually still meaningful given fastpath locking and such, but I guess we'll have to evaluate that. Greetings, Andres Freund -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs