pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Thomas Poty <thomas.poty@gmail.com>
To: pgsql-general@postgresql.org >> PG-General Mailing List <pgsql-general@postgresql.org>
Subject: Re: number and type of locks for an alter sequence
Date: Mon, 28 Jan 2019 07:55:33 -0800
Message-ID: <fb6f46f1-3f05-4f7a-2c39-74d6225f4c43@aklaver.com> (raw)
In-Reply-To: <CAN_ctng+MXgtr9j1g7U-iKsK--gCKfH0BTZtJSOO+RY9cv2xRQ@mail.gmail.com>
References: <CAN_ctng+MXgtr9j1g7U-iKsK--gCKfH0BTZtJSOO+RY9cv2xRQ@mail.gmail.com>

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.klaver@aklaver.com




view thread (2+ messages)

Message-ID: <fb6f46f1-3f05-4f7a-2c39-74d6225f4c43@aklaver.com>
Permalink:  ../fb6f46f1-3f05-4f7a-2c39-74d6225f4c43@aklaver.com/
Also on:    postgresql.org/message-id/fb6f46f1-3f05-4f7a-2c39-74d6225f4c43@aklaver.com

 · 

reply

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-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, thomas.poty@gmail.com
  Subject: Re: number and type of locks for an alter sequence
  In-Reply-To: <fb6f46f1-3f05-4f7a-2c39-74d6225f4c43@aklaver.com>
  References: <CAN_ctng+MXgtr9j1g7U-iKsK--gCKfH0BTZtJSOO+RY9cv2xRQ@mail.gmail.com> <fb6f46f1-3f05-4f7a-2c39-74d6225f4c43@aklaver.com>

* 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