Re: a SELECT FOR UPDATE question - Mailing list pgsql-general

From Michael Fuhr
Subject Re: a SELECT FOR UPDATE question
Date
Msg-id 20050208010941.GA43902@winnie.fuhr.org
Whole thread Raw
In response to a SELECT FOR UPDATE question  (Tim Vadnais <tvadnais@bwks.com>)
Responses Re: a SELECT FOR UPDATE question
List pgsql-general
On Mon, Feb 07, 2005 at 03:08:12PM -0800, Tim Vadnais wrote:
>
> If I select a row for update, is there anyway that someone can query to see
> if that row has been 'selected for update' and by whom?

I think you can infer that a process is working with a row in some
manner (UPDATE, SELECT FOR UPDATE) by looking at the row's xmax
column and checking pg_locks to see if any process is holding a
lock on the indicated transaction ID.  But why do you need to know?
What are you trying to do?

> Then I'd like to know if the session that 'SELECT(ed) FOR UPDATE' dies, will
> the server release the locked row?

Locks should be released when the holding transaction terminates.
I'm not sure if it's possible for a connection to end and leave a
lock behind, but if it is, I suspect it would be considered a bug
in the server that needed to be fixed.

(This sounds familiar, like I've participated in a thread on this
topic before.  I get the feeling Tom Lane is going to step in and
provide The Real Answer, and that my radio is about to start playing
"I Got You, Babe"....)

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/


pgsql-general by date:

Previous
From: Steve Atkins
Date:
Subject: Re: Creating an index-type for LIKE '%value%'
Next
From: Larry Rosenman
Date:
Subject: Re: Creating an index-type for LIKE '%value%'