From: Craig Ringer <craig@postnewspapers.com.au>
To: Richard Broersma <richard.broersma@gmail.com>
Cc: Sherif Kottapurath <sherifkm@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: locking problem in jdbc driver?
Date: Thu, 31 Dec 2009 09:01:50 +0800
Message-ID: <4B3BF7FE.4040001@postnewspapers.com.au> (raw)
In-Reply-To: <396486430912300846t519b787al4c6deba6d0d2cb25@mail.gmail.com>
References: <16cfd0b20912300829s47e5b081ma318561897d8d1bf@mail.gmail.com>
<396486430912300846t519b787al4c6deba6d0d2cb25@mail.gmail.com>
On 31/12/2009 12:46 AM, Richard Broersma wrote:
> On Wed, Dec 30, 2009 at 8:29 AM, Sherif Kottapurath<sherifkm@gmail.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: craig@postnewspapers.com.au, richard.broersma@gmail.com, sherifkm@gmail.com
Subject: Re: locking problem in jdbc driver?
In-Reply-To: <4B3BF7FE.4040001@postnewspapers.com.au>
References: <16cfd0b20912300829s47e5b081ma318561897d8d1bf@mail.gmail.com> <396486430912300846t519b787al4c6deba6d0d2cb25@mail.gmail.com> <4B3BF7FE.4040001@postnewspapers.com.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox