BUG #17140: pg_try_advisory_xact_lock produces a WARNINIG on unsuccessful lock

Started by PG Bug reporting formover 4 years ago3 messagesbugs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following bug has been logged on the website:

Bug reference: 17140
Logged by: Yuri Cherio
Email address: cherio@gmail.com
PostgreSQL version: 13.3
Operating system: Ubuntu Linux 20.04
Description:

Function "pg_try_advisory_xact_lock" triggers a WARNING message when the
lock is already owned by someone else. The documentation explicitly mentions
warnings on advisory unlock functions and those are understandable - the
developer should not try to unlock what's not owned.

However the advisory lock functions are there for this specific reason -
test whether a resource is locked or not. A negative test should not produce
a WARNING.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: PG Bug reporting form (#1)
Re: BUG #17140: pg_try_advisory_xact_lock produces a WARNINIG on unsuccessful lock

PG Bug reporting form <noreply@postgresql.org> writes:

Function "pg_try_advisory_xact_lock" triggers a WARNING message when the
lock is already owned by someone else.

I failed to duplicate this behavior. I did this in session A:

regression=# begin;
BEGIN
regression=*# select pg_try_advisory_xact_lock(1);
pg_try_advisory_xact_lock
---------------------------
t
(1 row)

then this in session B:

regression=# select pg_try_advisory_xact_lock(1);
pg_try_advisory_xact_lock
---------------------------
f
(1 row)

No warning...

regards, tom lane

#3Cherio
cherio@gmail.com
In reply to: Tom Lane (#2)
Re: BUG #17140: pg_try_advisory_xact_lock produces a WARNINIG on unsuccessful lock

I can not reproduce it any more.
There is a chance there were more forces at play when I was getting the
lock warning message.
Please forgive the disturbance.

On Wed, Aug 11, 2021 at 9:50 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:

Show quoted text

PG Bug reporting form <noreply@postgresql.org> writes:

Function "pg_try_advisory_xact_lock" triggers a WARNING message when the
lock is already owned by someone else.

I failed to duplicate this behavior. I did this in session A:

regression=# begin;
BEGIN
regression=*# select pg_try_advisory_xact_lock(1);
pg_try_advisory_xact_lock
---------------------------
t
(1 row)

then this in session B:

regression=# select pg_try_advisory_xact_lock(1);
pg_try_advisory_xact_lock
---------------------------
f
(1 row)

No warning...

regards, tom lane