From: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Petr Jelinek <petr.jelinek@2ndquadrant.com>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: pgsql-hackers@postgresql.org, Noah Misch <noah@leadboat.com>
Cc: Jason Petersen <jason@citusdata.com>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@postgresql.org>
Subject: Re: Concurrent ALTER SEQUENCE RESTART Regression
Date: Wed, 10 May 2017 09:24:50 -0700
Message-ID: <20170510162450.bzfktkeexezepf6c@alap3.anarazel.de> (raw)
In-Reply-To: <2913.1494426542@sss.pgh.pa.us>
References: <20170427062304.gxh3rczhh6vblrwh@alap3.anarazel.de>
<CAB7nPqTYQ+GZ9jP7FNHbTa+J5Z1k3ZmBrxvAhtOvpkH3k9j42g@mail.gmail.com>
<E77D2275-DA45-4F43-B00D-A9B113DFA9FB@anarazel.de>
<CAB7nPqQ=yHXxiWU2FuaC13L_5y7UG7R_OkJhWQbXYMJPXCDtNg@mail.gmail.com>
<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>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On 2017-05-10 10:29:02 -0400, Tom Lane wrote:
> Petr Jelinek <petr.jelinek@2ndquadrant.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: andres@anarazel.de, tgl@sss.pgh.pa.us, petr.jelinek@2ndquadrant.com, peter.eisentraut@2ndquadrant.com, noah@leadboat.com, jason@citusdata.com, michael.paquier@gmail.com
Subject: Re: Concurrent ALTER SEQUENCE RESTART Regression
In-Reply-To: <20170510162450.bzfktkeexezepf6c@alap3.anarazel.de>
References: <20170427062304.gxh3rczhh6vblrwh@alap3.anarazel.de> <CAB7nPqTYQ+GZ9jP7FNHbTa+J5Z1k3ZmBrxvAhtOvpkH3k9j42g@mail.gmail.com> <E77D2275-DA45-4F43-B00D-A9B113DFA9FB@anarazel.de> <CAB7nPqQ=yHXxiWU2FuaC13L_5y7UG7R_OkJhWQbXYMJPXCDtNg@mail.gmail.com> <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> <20170510162450.bzfktkeexezepf6c@alap3.anarazel.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox