Re: automatically detecting long timed locks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/12/07, Tino Schwarze <postgresql@xxxxxxx> wrote:
> Hi there,
>
> is there an easy way to detect locks which are held for a very long
> time? We've got some problems with a database here where a lock is held
> for 1 or 2 hours though the operation should be very quick. A lot of
> other processes are then waiting for the lock to become available.
>
> We would like to query for "lock on table xyz being held for more than
> 60 seconds" or the other way around "query has been waiting for lock on
> table xyz for more than 60 seconds".
>
> Of course, we get log entries like "LOG:  duration: 8544285.789 ms
> execute <unnamed>: lock table "xyz" in exclusive mode", but this is
> AFTER the lock got acquired. We'd like to notice if lock acquisition
> takes very long so we can look around and figure out what's wrong.
>
> How can we achieve this?

I use something like this:

select *, age(transactionid) from pg_locks where locktype='transactionid';

to see which transactions are old.  the higher the age the older the
transaction is.

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
       message can get through to the mailing list cleanly

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux