Re: Transaction-scope advisory locks

From: Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>
To: Marko Tiikkaja <marko(dot)tiikkaja(at)cs(dot)helsinki(dot)fi>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Transaction-scope advisory locks
Date: 2011-01-17 07:28:10
Message-ID: AANLkTimya9pVbe92mCXGrj9S4xFmSHNRu9GtCS9z+rnG@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jan 16, 2011 at 06:20, Marko Tiikkaja
<marko(dot)tiikkaja(at)cs(dot)helsinki(dot)fi> wrote:
> Here's the latest version of the patch.  It now uses the API proposed by
> Simon, but still lacks documentation changes, which I'm going to send
> tomorrow.

Here is a short review for Transaction scoped advisory locks:
https://commitfest.postgresql.org/action/patch_view?id=518

== Features ==
The patch adds pg_[try_]advisory_xact_lock[_shared] functions.
The function names follows the past discussion -- it's better than
"bool isXact" argument or changing the existing behavior.

== Coding ==
The patch itself is well-formed and be applied cleanly.
I expect documentation will come soon.
There is no regression test, but we have no regression test for
advisory locks even now. Tests for lock conflict might be difficult,
but we could have single-threaded test for lock/unlock and pg_locks view.

== Questions ==
I have a question about unlocking transaction-scope advisory locks.
We cannot unlock them with pg_advisory_unlock(), but can unlock with
pg_advisory_unlock_all(). It's inconsistent behavior.
Furthermore, I wonder we can allow unlocking transaction-scope locks
-- we have LOCK TABLE but don't have UNLOCK TABLE.

postgres=# BEGIN;
BEGIN
postgres=# SELECT pg_advisory_xact_lock(1);
pg_advisory_xact_lock
-----------------------

(1 row)

postgres=# SELECT pg_advisory_unlock(1);
WARNING: you don't own a lock of type ExclusiveLock
pg_advisory_unlock
--------------------
f
(1 row)

postgres=# SELECT pg_advisory_unlock_all();
pg_advisory_unlock_all
------------------------

(1 row)

postgres=# ROLLBACK;
ROLLBACK

--
Itagaki Takahiro

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Itagaki Takahiro 2011-01-17 07:51:56 Re: texteq/byteaeq: avoid detoast [REVIEW]
Previous Message Pavel Stehule 2011-01-17 07:13:28 Re: texteq/byteaeq: avoid detoast [REVIEW]