Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8S2T-0002dO-5d for pgsql-bugs@arkaria.postgresql.org; Wed, 10 May 2017 13:52:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d8S2S-00087r-3z for pgsql-bugs@arkaria.postgresql.org; Wed, 10 May 2017 13:52:24 +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 1d8S2R-00087V-DH for pgsql-bugs@postgresql.org; Wed, 10 May 2017 13:52:23 +0000 Received: from mail-wr0-x22b.google.com ([2a00:1450:400c:c0c::22b]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1d8S2N-0007D6-TS for pgsql-bugs@postgresql.org; Wed, 10 May 2017 13:52:22 +0000 Received: by mail-wr0-x22b.google.com with SMTP id l9so45300851wre.1 for ; Wed, 10 May 2017 06:52:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=D3Ht175AdhfMB0wP9lOM/ZD9wAArS5NcyxqBuBdcp30=; b=vqaKEE97Q0mNsLLXT2uAKr1Tx5NExeHFi4Mazf7cgMLbsnKTr8d7PTYgWXorLF1/W+ +mhrE8T/hQ3ZUyXD/hL6LlFMETRFV9ABeIIu/ehS5xJK4ErFmqaqw93PQce6p0VGUo6N p12TunJ9pE7NSMpACBrCquI9dba2YfwOZQV1rCOA/W12GaNJQbd8bva9pz69G30lWW0H /Ixz2g7AE8P0xzA/vCrhUEuMWmyq9bSz8my1vpEWtZzFKEzC2tWpyEV6nfPDN9EComlI r/jHAIEp4UMciIXlhCNWGUR5I2BS/BbNl/AlmNgR3G9Ogt39Rg36UhlwZiMFrBco9ATe 4lGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=D3Ht175AdhfMB0wP9lOM/ZD9wAArS5NcyxqBuBdcp30=; b=uCYnDa4OzemhukiuBcMLfkq9qEpbQIK+wvYUazzALyFX0s4IJd2AGH4hbhCDk3fsGy Zj2GXDuEMEz2e1bXpVPRRGZo1+H3UAsuoNacPxWkr57/r5wmnrrPYlcWHPLzVM56vb4J wGBw/+xZc5ws1ACyPYeyJLDob+AfzDIROvSzINHi/FkD1F5IvxCF6F7quEdr3avgLVNW r+6+vx3Jz0+Az+Fh2pk728f+k+t/byJigZheQRRAQRXYdZRKNla6fa3C0fMf/QDCxOQf aVeYzIVwvxBFMiF25lt3/tl3GBNwAvRqozP9qu+P4NLvDGFiwJNXbHr79rzzOKaccVqT Pikg== X-Gm-Message-State: AODbwcBy/XzeX0Q/l5LPXyckXIjQRVtE0DTzbOwcpPntuUC8k97Y2BrC w/oamrMPBpKM7ABg+Lvtc7kO6ZbnInT2jPIVvg7jVW/TzY2qHA694PDBf3He+gK1OQGkb0NrBiH ukmHz5bh7DudQe/amtQRwdf99ijTD8brxNE+DFwzT0xmVT+u7OPVX1IluW1KvtusTHp+fJ96M/g == X-Received: by 10.28.141.140 with SMTP id p134mr1022666wmd.54.1494424337108; Wed, 10 May 2017 06:52:17 -0700 (PDT) Received: from [192.168.0.105] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id l27sm2190685wrb.65.2017.05.10.06.52.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 May 2017 06:52:16 -0700 (PDT) Subject: Re: Concurrent ALTER SEQUENCE RESTART Regression To: Peter Eisentraut , Andres Freund , pgsql-hackers@postgresql.org References: <99a009ea-1797-5b82-f3d3-eb4a5a8eb5dc@2ndquadrant.com> <20170427011258.2tpv55b6leqe2uva@alap3.anarazel.de> <1e5bb916-fd58-3995-851b-6875c6dd73eb@2ndquadrant.com> <20170427055806.uviqrl57lkgcmmmy@alap3.anarazel.de> <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> Cc: Noah Misch , Jason Petersen , Michael Paquier , PostgreSQL mailing lists From: Petr Jelinek Message-ID: <20d59e42-4a08-fa34-29df-9f54b3ef5ba7@2ndquadrant.com> Date: Wed, 10 May 2017 15:52:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <4521f870-bb1f-1b29-3b3f-42419696efe7@2ndquadrant.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) 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 10/05/17 07:09, Peter Eisentraut wrote: > On 5/7/17 19:43, Andres Freund wrote: >> 3. Keep the catalog, make ALTER properly transactional, blocking >> concurrent nextval()s. This resolves the issue that nextval() can't >> see the changed definition of the sequence. > > This was the intended choice. > > [...] > > 5. nextval() disregarding uncommitted ALTER SEQUENCE changes. In > Currently, it goes ahead even if there is an uncommitted ALTER > SEQUENCE pending that would prohibit what it's about to do (e.g., > MAXVALUE change). > > 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? Looking at the changes to open_share_lock(), I wonder if we need to have lock level as parameter so that lastval() is not blocked. -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs