X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EA031D1B269 for ; Thu, 22 Jul 2004 18:44:53 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 70332-03 for ; Thu, 22 Jul 2004 21:44:47 +0000 (GMT) Received: from pegasus.host4u.net (pegasus.host4u.net [209.150.128.41]) by svr1.postgresql.org (Postfix) with ESMTP id A5B16D1B262 for ; Thu, 22 Jul 2004 18:44:43 -0300 (ADT) Received: from graciousstyle.com (ca-stmnca-cuda1-blade2b-207.stmnca.adelphia.net [68.65.195.207]) by pegasus.host4u.net (8.11.6/8.11.6) with ESMTP id i6MLid310968; Thu, 22 Jul 2004 16:44:39 -0500 Message-ID: <4100353D.9080202@graciousstyle.com> Date: Thu, 22 Jul 2004 14:44:29 -0700 From: Si Chen Reply-To: schen@graciousstyle.com Organization: Gracious Style User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en, zh-cn MIME-Version: 1.0 To: Tom Lane Cc: pgsql-general@postgresql.org Subject: Re: [ADMIN] how to find transaction associated with a lock References: <41001296.3090609@graciousstyle.com> <12341.1090529103@sss.pgh.pa.us> In-Reply-To: <12341.1090529103@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_RFCI, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/683 X-Sequence-Number: 63282 Hi Tom, Thanks for the reply. I looked in pg_stat_activity and it shows database tables and process ids. So I should be using the pid next to the ExclusiveLock to see what database it is working on, right? Now, the problem that I had was this: I have a java application that access postgresql (7.3.2) via jdbc. It was running fine for a while, then of all sudden, against one table, the INSERT would simply hang. It would INSERT fine on many other tables and the application could still run, except for INSERTs involving this particular table (unfortunately, an important table.) Someone else had suggested that it was perhaps a lock on that particular table. So I looked up view locking and then thought that this was where the bug was occurring. Do you think I'm looking down the wrong path? Might it be something else (like the lack of a recent vacuuming or fsync not being set to true in postgresql.conf) that was causing this bug? Thanks so much for your help! Si Chen Tom Lane wrote: >Si Chen writes: > > >>Does anyone know of a way to go from transactions identifiers to the >>actual transaction--which tables, which statements, etc. etc.? >> >> > >See pg_stat_activity. > >The pg_locks entries you are looking at do *not* represent table locks >of any kind. This: > > >>NULL NULL 3366868 27149 ExclusiveLock TRUE >> >> >simply says that transaction 3366868 is still running. This: > > >>NULL NULL 3366868 1069 ShareLock FALSE >> >> >says that process 1069 has elected to wait until transaction 3366868 >finishes. Normally the reason for doing that would be that transaction >3366868 holds a row lock (SELECT FOR UPDATE lock) on some row that >process 1069's transaction wants to acquire row lock on. > >However, I suspect what you are really wishing is to find out the >individual row that is being contended for, and there is not enough >information in the system views to do that (mainly because we do not >keep per-row locking information in shared memory). > > regards, tom lane > > >