Re: number and type of locks for an alter sequence

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Thomas Poty <thomas(dot)poty(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: number and type of locks for an alter sequence
Date: 2019-01-28 15:55:33
Message-ID: fb6f46f1-3f05-4f7a-2c39-74d6225f4c43@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 1/28/19 6:07 AM, Thomas Poty wrote:
> Hello ,
>
> In PG10, when I am altering a sequence, i see 2 locks in pg_locks
> matching my sequence:
> a RowExclusiveLock
> and a ShareRowExclusiveLock
>
> My question is Why 2 locks?
> Someone on irc said it was for catalog but i am no sure because
> pg_locks.relationid is the same for the 2 locks.
>
> At the same time, If I am trying to call nextval with an othersession,
> the session wants to get a RowExclusiveLock on the sequence.
>
> So, to me, the lock ShareRowExclusiveLock is when the sequence is beeing
> altered.
> And the RowExclusiveLock is for concurent access between alter/drop
> sequence and nextval/setval/curval/lastval.
>
> Documentation seems not talking about this...
> (https://www.postgresql.org/docs/10/explicit-locking.html) Maybe should
> I open a ticket?

A sequence, for practical purposes, is a table. So in the above
substitute TABLE with SEQUENCE:

>
> Thanks

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ruben Rubio Rey 2019-01-28 21:32:21 Re: Geographical multi-master replication
Previous Message Susan Hurst 2019-01-28 15:49:52 Re: Displaying Comments in Views