Forum OpenACS Q&A: Re: PostgreSQL deadlock? Need some help here.

Collapse
Posted by Jonathan Ellis on
try this:

select c.relname, l.*
from pg_class c, pg_locks l
where c.relfilenode = l.relation;

this gives you something like

   relname   | relation | database | transaction |  pid  |      mode       | granted
-------------+----------+----------+-------------+-------+-----------------+---------
 pg_locks    |    16759 |  8992864 |             | 18220 | AccessShareLock | t
 armor       |  8994951 |  8992864 |             |  7309 | AccessShareLock | t
 pg_class    |     1259 |  8992864 |             | 18220 | AccessShareLock | t
 armor_v     |  8994977 |  8992864 |             |  7309 | AccessShareLock | t
 items       |  8994975 |  8992864 |             |  7309 | AccessShareLock | t
 armor_types |  8994628 |  8992864 |             |  7309 | AccessShareLock | t
look for locks that haven't been granted, and see what has a granted lock on that relation.