Re: Can pessimistic locking be emulated? - Mailing list pgsql-hackers

From Merlin Moncure
Subject Re: Can pessimistic locking be emulated?
Date
Msg-id 303E00EBDD07B943924382E153890E5434A91D@cuthbert.rcsinc.local
Whole thread Raw
In response to Can pessimistic locking be emulated?  ("Merlin Moncure" <merlin.moncure@rcsonline.com>)
Responses Re: Can pessimistic locking be emulated?
Re: Can pessimistic locking be emulated?
List pgsql-hackers
I was referring to 10.3 in the administrator's guide, regarding the
pg_lock view.  According to the documentation, the view only contains
table level locks.  However, the view also contains an xid for
transactions.  The unclear part, at least to me, was what the role of
the xid was in the view and if it could be used to produce a list of
locked tuples somehow.  The xid is referred to as a 'lockable object'.
I wasn't sure of the xid's role in the mix.  I see now how it all works
together.

In my case, being able to view outstanding row level locks would be
enormously useful.  I'm assuming this is not possible for structural or
performance reasons.  I'm aware of the possible nasty side affects of
repeated query calls to the lock manager.  I'm also aware what I'm
asking about may be folly or silly, my understanding of how mvcc and
transactions work together is not very refined.

A curious thought struck me: does the pg_lock view follow the mvcc
rules, i.e. if you query the pg_lock view inside a transaction, and an
external effect introduces new locks into the server are you able to see
those locks?

Merlin
> > 1. Can you query if a tuple is locked by another transaction (the
> > documentation unclearly suggests this can't be done via the pg_lock
> > view) before executing select for update...?

> Where did you find this?

>
> Regards, Christoph
>



pgsql-hackers by date:

Previous
From: Christoph Haller
Date:
Subject: Re: Can pessimistic locking be emulated?
Next
From: Robert Treat
Date:
Subject: Re: Free-space-map management thoughts