Re: view row-level locks - Mailing list pgsql-general

From Vivek Khera
Subject Re: view row-level locks
Date
Msg-id FCD1881E-A6E1-4669-8BE6-D4BCCC0E7A8F@khera.org
Whole thread Raw
In response to Re: view row-level locks  (Richard Huxton <dev@archonet.com>)
Responses Re: view row-level locks
List pgsql-general
On Jul 11, 2008, at 4:24 AM, Richard Huxton wrote:

> If you just want to see if a lock has been taken (e.g. SELECT FOR
> UPDATE) then that shows in pg_locks. If you want details on the
> actual rows involved, then you probably want "pgrowlocks" mentioned
> in Appendix F. Additional Supplied Modules.

pg_locks tells you the page/tuple so you can select it with those
values.  Assuming they are page=132 and tuple=44 and relation=99 you
can find the tuple thusly:

select relname from pg_class where oid=99;

then given that relname=mytable,

select * from mytable where ctid='(132,44)';

and there you have the row.

What I need to see is which locks my other queries are waiting on.  If
pg_locks would show me which process is also blocking on this lock,
I'd be a much happier man today (actually, last tuesday, when this was
a problem for me to debug something).


pgsql-general by date:

Previous
From: Augustin Amann
Date:
Subject: Re: Update / Lock (and ShareLock) question
Next
From: Tom Lane
Date:
Subject: Re: Update / Lock (and ShareLock) question