Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 3167E9FA5AB for ; Wed, 12 Sep 2007 19:03:03 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 72558-10 for ; Wed, 12 Sep 2007 19:02:54 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.169]) by postgresql.org (Postfix) with ESMTP id 29C419F9A8D for ; Wed, 12 Sep 2007 19:02:57 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id j3so342293ugf for ; Wed, 12 Sep 2007 15:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=GB5BGWixyvhwK4Ts2xich+Mqvxsw8SAgqC6HgSaF84s=; b=icv9jmYqu0BtUsmzgFJOQxVq1t3AaC+nKiehpi9d9RQUtKRbnXVrq102erTgq391sD4BOpd0ZDa4zWbb5qFHKBPm0ZB3/1Rzz7ZE6uQaukwbzBIgfxcr9ErMnniXs3njF+O/Sv5xyjhgh/TmdLYrkruIxIydVzZDahudgWoveCs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=SrlKJvNueesTLsDVtQTjI9uagJT51QPNN26sGNd9wTeae7gJPk7I/ZAWtKHiOtZ+PDxKWUKaS4hBqrCn8JKMX/0LkDh2boZ4ayyvwdioqNnINzhEiamOwh9BIgbWeqOK9f/vNwKM9/BIs+yjNeKHgsRDG/w14TmQuc1FTJvz7E8= Received: by 10.67.16.2 with SMTP id t2mr2303670ugi.1189634576601; Wed, 12 Sep 2007 15:02:56 -0700 (PDT) Received: by 10.66.220.7 with HTTP; Wed, 12 Sep 2007 15:02:56 -0700 (PDT) Message-ID: Date: Wed, 12 Sep 2007 17:02:56 -0500 From: "Scott Marlowe" To: "Tino Schwarze" Subject: Re: automatically detecting long timed locks Cc: pgsql-admin@postgresql.org In-Reply-To: <20070912204657.GC29139@easy2.in-chemnitz.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20070912204657.GC29139@easy2.in-chemnitz.de> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/85 X-Sequence-Number: 26846 On 9/12/07, Tino Schwarze 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 : 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.