X-Original-To: pgsql-admin-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 4F2E39FB3BA for ; Wed, 23 Aug 2006 17:39:25 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 82543-01 for ; Wed, 23 Aug 2006 20:39:24 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from mail.gmx.net (mail.gmx.de [213.165.64.20]) by postgresql.org (Postfix) with SMTP id 462899FB1F0 for ; Wed, 23 Aug 2006 17:39:24 -0300 (ADT) Received: (qmail invoked by alias); 23 Aug 2006 20:39:22 -0000 Received: from dslb-084-063-010-136.pools.arcor-ip.net (EHLO colt.pezone.net) [84.63.10.136] by mail.gmx.net (mp037) with SMTP; 23 Aug 2006 22:39:22 +0200 X-Authenticated: #495269 From: Peter Eisentraut To: andre Subject: Re: [GENERAL] How to detect Postgres deadlocks? Date: Wed, 23 Aug 2006 22:39:22 +0200 User-Agent: KMail/1.9.3 Cc: pgsql-admin@postgresql.org References: <6c3954020608231245l3035ffbby41cfdbfac2d37326@mail.google.com> In-Reply-To: <6c3954020608231245l3035ffbby41cfdbfac2d37326@mail.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200608232239.22827.peter_e@gmx.net> X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200608/248 X-Sequence-Number: 22791 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/