Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id AAA2B6326DA for ; Wed, 30 Dec 2009 21:02:13 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 46176-04 for ; Thu, 31 Dec 2009 01:01:55 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by mail.postgresql.org (Postfix) with ESMTP id 7EB68632662 for ; Wed, 30 Dec 2009 21:02:02 -0400 (AST) Received: from localhost (access [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 141821E043C; Thu, 31 Dec 2009 09:01:57 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (access.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ay2zGj8w4ucb; Thu, 31 Dec 2009 09:01:55 +0800 (WST) Received: from [10.1.1.6] (124-169-133-89.dyn.iinet.net.au [124.169.133.89]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id D8C001E043A; Thu, 31 Dec 2009 09:01:54 +0800 (WST) Message-ID: <4B3BF7FE.4040001@postnewspapers.com.au> Date: Thu, 31 Dec 2009 09:01:50 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0 MIME-Version: 1.0 To: Richard Broersma CC: Sherif Kottapurath , pgsql-jdbc@postgresql.org Subject: Re: locking problem in jdbc driver? References: <16cfd0b20912300829s47e5b081ma318561897d8d1bf@mail.gmail.com> <396486430912300846t519b787al4c6deba6d0d2cb25@mail.gmail.com> In-Reply-To: <396486430912300846t519b787al4c6deba6d0d2cb25@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.359 tagged_above=-10 required=5 tests=AWL=0.240, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200912/113 X-Sequence-Number: 20194 On 31/12/2009 12:46 AM, Richard Broersma wrote: > On Wed, Dec 30, 2009 at 8:29 AM, Sherif Kottapurath wrote: > >> All threads shown here are operating on >> the same table, and they are all parts of transactions involving multiple tables. >> deadlock detection is set for 1 sec and no dedlocks are reported by postgres. > > From my experience, PostgreSQL doesn't report deadlocks. It should, at least with default settings. Failure to do so would, I expect, be considered a bug. How, exactly, are you creating a deadlock situation for your testing? > However, unless you've set your transaction isolation level to > SERIALIZABLE ( the default isolation level is READ COMMITED), you will > not be getting deadlocks from PostgreSQL. Sure you will. In READ COMMITTED: CREATE TABLE a ( ); CREATE TABLE b ( ); T1: LOCK TABLE a; T2: LOCK TABLE b; T2: LOCK TABLE a; T1: LOCK TABLE b; then one of the transactions will be aborted with: ERROR: deadlock detected DETAIL: Process 13674 waits for AccessExclusiveLock on relation 57791 of database 57071; blocked by process 13672. Process 13672 waits for AccessExclusiveLock on relation 57788 of database 57071; blocked by process 13674. HINT: See server log for query details. What *doesn't* happen in read committed isolation is serialization failures. > Also, IIRC the PostgreSQL JDBC driver only allows a single thread to > access a connection object at a time. Yep. It's thread safe, but a given connection can only be doing one thing at a time, so other Java threads will wait for access to the connection. -- Craig Ringer