BUG #17140: pg_try_advisory_xact_lock produces a WARNINIG on unsuccessful lock
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.
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
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