Re: [GENERAL] How to detect Postgres deadlocks?

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: andre <andre(at)google(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: [GENERAL] How to detect Postgres deadlocks?
Date: 2006-08-23 20:39:22
Message-ID: 200608232239.22827.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

andre wrote:
> 1) Which sql queries should I use to detect deadlocks while they are
> happening? I see the deadlock info on the log file, but I'd like to
> query the database to see them as they happen...

Since deadlocks are broken up within one second, it will be hard to
actually see them. You could crank up the deadlock timeout and then
query pg_locks and infer cycles from there. From there you can also
move over to the statistics tables to see what the processes are
currently doing. But the system won't actually tell you that there is
a deadlock until the timeout is over. If you have special requirements
like that, you need to patch the source.

The other option is to decorate your server log lines with pids and such
that you can link from the deadlock error message to the logged
statements.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Scott Marlowe 2006-08-23 20:40:22 Re: [GENERAL] How to detect Postgres deadlocks?
Previous Message andre 2006-08-23 19:45:56 How to detect Postgres deadlocks?

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2006-08-23 20:40:22 Re: [GENERAL] How to detect Postgres deadlocks?
Previous Message Joe Conway 2006-08-23 20:31:12 Re: pl/R problem