Re: Transaction-scope advisory locks

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, Marko Tiikkaja <marko(dot)tiikkaja(at)cs(dot)helsinki(dot)fi>, Szymon Guz <mabewlun(at)gmail(dot)com>
Subject: Re: Transaction-scope advisory locks
Date: 2010-12-14 14:30:37
Message-ID: 201012141530.37300.andres@anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tuesday 14 December 2010 15:19:32 Merlin Moncure wrote:
> On Tue, Dec 14, 2010 at 7:07 AM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> > On Tuesday 14 December 2010 00:14:22 Marko Tiikkaja wrote:
> >> The lock space is the same though, but I don't feel strongly about it.
> >
> > I feel strongly that it needs the same locking space. I pretty frequently
> > have the need for multiple clients trying to acquiring a lock in
> > transaction scope (i.e. for accessing the cache) and one/few acquiring
> > it in session scope (for building the cache).
>
> Not that I'm necessarily against the proposal, but what does this do
> that can't already be done by locking a table or a table's row?
1. trylock without raising errors (the other possibility is nowait, but that
doesnt work very well as it ERRORs).

2. mixing session and transaction scope (I would like to have that e.g. for
materialized views. The writers uses session scope and the readers use
transaction scope. Its not that easy to make code ERROR/exception safe when
you only control some view or such. In contrast the computationally expensive
part of computing the materialized view should be way much more easy to do
sensibly in session scope).

3. nonlocking dequeuing of a table-based queue can e.g. be done with advisory
locks but not with row level locks.

Andres

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2010-12-14 14:34:55 Re: Instrument checkpoint sync calls
Previous Message Alvaro Herrera 2010-12-14 14:29:05 Re: Instrument checkpoint sync calls