Re: pg_try_advisory_lock is waiting? - Mailing list pgsql-general

From Tom Lane
Subject Re: pg_try_advisory_lock is waiting?
Date
Msg-id 2858894.1643414894@sss.pgh.pa.us
Whole thread Raw
In response to pg_try_advisory_lock is waiting?  (Mladen Gogala <gogala.mladen@gmail.com>)
Responses Re: pg_try_advisory_lock is waiting?  (Mladen Gogala <gogala.mladen@gmail.com>)
List pgsql-general
Mladen Gogala <gogala.mladen@gmail.com> writes:
> I tried the following:

> _*1st Session:*_

> mgogala=# begin transaction;
> BEGIN
> mgogala=*# update emp set sal=sal*1 where empno=7934;
> UPDATE 1
> mgogala=*#

> _*2nd Session:*_

> mgogala=# begin transaction;
> BEGIN
> mgogala=*# select pg_try_advisory_lock(0) from (select ename from emp 
> where empno=7934 for update) as tbl;

> To my infinite surprise, "pg_advisory_lock" is waiting.

I doubt it.  I think the FOR UPDATE in the sub-select is blocked
because the other session has an uncommitted update on the row
it wants to lock.  This command won't reach the pg_try_advisory_lock
call until that row lock comes free.

            regards, tom lane



pgsql-general by date:

Previous
From: Michael Lewis
Date:
Subject: Re: pg_try_advisory_lock is waiting?
Next
From: Mladen Gogala
Date:
Subject: Re: pg_try_advisory_lock is waiting?