Advisory lock grant order

From: Yossi Cohen <yossic00(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Advisory lock grant order
Date: 2014-09-09 09:44:10
Message-ID: CAEfuueTFjh6Mn-yiARREcDjWskXvoA6eEGhw=wKFGHN5F=Bx1g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

If I request an advisory lock (pg_advisory_lock) with the same key from
several sessions; will the lock be granted in the same order as it was
requested?
I.e. if for example:

session 1: select pg_advisory_lock(1); -- acquires the lock
then
session 2: select pg_advisory_lock(1); -- blocks waiting for the lock
then
session 3: select pg_advisory_lock(1); -- blocks waiting for the lock

then
session 1: select pg_advisory_unlock(1); -- releases the lock

Is it guaranteed that now session 2 will be granted the lock because it
requested the lock before session 3?

Thanks,
Yossi

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ramesh T 2014-09-09 10:36:50 stackbuilder
Previous Message Michael Paquier 2014-09-09 07:50:40 Re: Crash in 9.4 Beta when partially collapsing left outer joins