X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2AA7DDBAF3 for ; Fri, 18 Nov 2005 14:28:37 -0400 (AST) 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 68019-09 for ; Fri, 18 Nov 2005 18:28:36 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id 20772DBAF1 for ; Fri, 18 Nov 2005 14:28:33 -0400 (AST) Received: (qmail 15959 invoked by uid 1112); 18 Nov 2005 18:31:23 -0000 Date: Fri, 18 Nov 2005 13:31:23 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Vit Timchishin cc: "pgsql-jdbc@postgresql.org" Subject: Re: Deadlock problem In-Reply-To: <200511181209.000000EC@dev-null> Message-ID: References: <200511181209.000000EC@dev-null> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[AWL=0.000] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200511/112 X-Sequence-Number: 14210 On Fri, 18 Nov 2005, Vit Timchishin wrote: > I have an multithreaded java application using postgresql. I am using UR > mode (handling locking internally) and wa shoping to have no problems > with locks. But now I have locking porlbme where there is only one > thread calling posgresql and locking in wait. Looking at pg_lock I can > see a lot of locks each holding exclusive a transaction (other two > fields are empty). And for one transaction there is one PID holding > Exclusive Lock and another waiting for shared lock for same transaction. > I suppose that this means that I've first used connection object from > one thread and this thread pid (linux x86-64) took exclusive lock and > now another thread tries to use same connection and is going into lock. > Am I correct? If so, why this exclusive locks are help while there no > other queries executed? Or does this mean I can't use same connection > object from different threads? I'm a little bit unclear on how you are using connections. Does your application have only one Connection object that it shares among various threads? If this is the case the postgresql jdbc driver will block a thread when another thread is executing a statement from the same connection. The server does not support multiplexing queries so the driver can only allow one to execute at any given time. If this is the case you may want to open more than one Connection in your application. This situation cannot cause a block on the server side because a Connection cannot block itself. If you are blocked on the server side (with only one Connection) then you must be waiting for another connection's resources, perhaps from another application or maintenence command. Kris Jurka