Re: SELECT .. FOR UPDATE: find out who locked a row

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Enrico Thierbach <eno(at)open-lab(dot)org>
Cc: Melvin Davidson <melvin6925(at)gmail(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: SELECT .. FOR UPDATE: find out who locked a row
Date: 2018-03-15 22:05:12
Message-ID: 20180315220512.GV2416@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Greetnigs,

* Enrico Thierbach (eno(at)open-lab(dot)org) wrote:
> I guess with your query I can figure out which connection holds a lock, but
> it seems I cannot correlate those locks to the rows which actually are
> locked, since `pg_locks` seems not to reference this in any way.

What I gave you would work, or you could use the pgrowlocks extension:

https://www.postgresql.org/docs/current/static/pgrowlocks.html

Using pgrowlocks will be slow if you have a lot of records in the table
though, hence the other approach I mentioned since it sounds like you
know the ID that you're interested in.

Thanks!

Stephen

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Foolish Ewe 2018-03-15 23:00:09 Want to disable fully qualified table names on pg_dump in pg_dump (PostgreSQL) 9.6.8
Previous Message Enrico Thierbach 2018-03-15 21:55:10 Re: SELECT .. FOR UPDATE: find out who locked a row