Re: Regarding experiencing

From: Blessy Thomas <blessy456bthomas(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Regarding experiencing
Date: 2025-02-11 09:39:16
Message-ID: CAJyyjtAZxFGuynAKabj7xOsy9YYMJdAU5zcLTg6Ya7AqgKcbdg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

These are the commands I have run in the terminal
psql (17.0)
Type "help" for help.

postgres=# SELECT pg_advisory_lock_shared(1001); //initialising the shared
lock
pg_advisory_lock_shared
-------------------------

(1 row)

postgres=# SELECT pg_advisory_lock(1001); //exclusive lock
pg_advisory_lock
------------------

(1 row)....
now i have logged in session 2 to check whether both locks are granted
without conflict, heres the output :
postgres=# SELECT * FROM pg_locks WHERE locktype = 'advisory';
locktype | database | relation | page | tuple | virtualxid | transactionid
| classid | objid | objsubid | virtualtransaction | pid | mode |
granted | fastpath | waitstart
----------+----------+----------+------+-------+------------+---------------+---------+-------+----------+--------------------+------+---------------+---------+----------+-----------
advisory | 5 | | | | |
| 0 | 1001 | 1 | 3/0 | 7126 | ShareLock |
t | f |
advisory | 5 | | | | |
| 0 | 1001 | 1 | 3/0 | 7126 | ExclusiveLock |
t | f |
(2 rows)

UNDERSTANDING : The same resource ( oid and pid) are allocate to both
exclusive and shared lock . I am also attaching the screenshots.

On Tue, 11 Feb 2025 at 14:01, Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
wrote:

> Hello
>
> On 2025-Feb-11, PG Doc comments form wrote:
>
> > ISSUE : According to the above paragraph , locks should either be shared
> or
> > exclusive. But when I tried assigning a shared lock and exclusive lock
> > without unlock of the shared lock , it doesn't show a conflict. I think
> this
> > may contradict what is said in above paragraph of documentation. Can you
> > enlighten me more on this , regarding the understanding if my assumption
> is
> > wrong.
>
> Your understanding is correct -- there should be a conflict. The lack
> of one suggests that you're using the lock interfaces incorrectly.
> Please show the exact commands you're running. Maybe there's something
> about the documentation text that needs to be made clearer.
>
> > I could have attached snaps of the same but I don't find an
> > attachment option.
>
> True. You can reply to this email with attachments. However, I would
> instead suggest to copy and paste text from terminal window(s), rather
> than screenshots.
>
> --
> Álvaro Herrera PostgreSQL Developer —
> https://www.EnterpriseDB.com/
>

Attachment Content-Type Size
image/png 30.4 KB
image/png 47.2 KB

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Álvaro Herrera 2025-02-11 10:25:57 Re: Regarding experiencing
Previous Message Álvaro Herrera 2025-02-11 08:31:01 Re: Regarding experiencing