pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: Oliver Jowett <oliver@opencloud.com>
Cc: taktos@gmail.com
Cc: pgsql-jdbc@postgresql.org
Subject: Re: commit and rollback don't throw exceptions when they should
Date: Wed, 21 Oct 2009 09:40:58 -0500
Message-ID: <4ADED72A020000250002BC40@gw.wicourts.gov> (raw)
In-Reply-To: <4ADF0210.4010100@opencloud.com>
References: <4ADDCCE1020000250002BBEA@gw.wicourts.gov>
	<4ADF0210.4010100@opencloud.com>

Oliver Jowett <oliver@opencloud.com> wrote:
> Kevin Grittner wrote:
> 
>> I could take a shot at a patch if nobody disagrees with making this
>> change.
> 
> What exactly is the change you're suggesting?
 
I need to go back and see if any earlier versions conflict with this,
but recent version of the Java API specify that commit and rollback
should throw a SQLException if autoCommit is true.  The driver
currently returns without any warning or exception, and without doing
anything.
 
There is a similar requirement for these methods when a distributed
transaction is active, which is only mentioned in Java 6 javadocs, but
seems as though it makes sense whenever distributed transactions are
used.  Java 6 also explicitly mentions that an exception should be
thrown for attempts to use these methods on a closed connection,
although that could arguably fall under the earlier language requiring
an exception when "a database access error occurs" -- since you can't
access a database across a closed connection.
 
This surfaced because a popular connection pooler is reportedly
failing to behave correctly when the connection is lost (for example,
if PostgreSQL is restarted).  It works with other databases the user
has tested.  The user believes it to be because the rollback method is
not throwing an exception on the closed connection.  I haven't
independently confirmed this yet.  (Takiguchi, if you have a
self-contained test case, that would save me some time on that point.)
 
I'm suggesting that we throw exceptions for all of the above.  It
worries me that some existing applications may be relying on the
silent success of a commit or rollback when autoCommit is active,
though.  That's contrary to the javadocs for the API, but there's
still the backwards compatibility issue for current PostgreSQL
users....
 
-Kevin



view thread (12+ messages)  latest in thread

Message-ID: <4ADED72A020000250002BC40@gw.wicourts.gov>
Permalink:  ../4ADED72A020000250002BC40@gw.wicourts.gov/
Also on:    postgresql.org/message-id/4ADED72A020000250002BC40@gw.wicourts.gov

 · 

reply

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: Kevin.Grittner@wicourts.gov, oliver@opencloud.com, taktos@gmail.com
  Subject: Re: commit and rollback don't throw exceptions when they should
  In-Reply-To: <4ADED72A020000250002BC40@gw.wicourts.gov>
  References: <4ADDCCE1020000250002BBEA@gw.wicourts.gov> <4ADF0210.4010100@opencloud.com> <4ADED72A020000250002BC40@gw.wicourts.gov>

* 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