pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Lewis <mark.lewis@mir3.com>
To: kevin@mtel.co.uk
Cc: pgsql-jdbc@postgresql.org
Subject: Re: postgres jdbc transaction problem surfaces at times
Date: Wed, 12 Apr 2006 09:38:12 -0700
Message-ID: <1144859893.5541.246.camel@archimedes> (raw)
In-Reply-To: <1144856469.014948.89160@j33g2000cwa.googlegroups.com>
References: <1144856469.014948.89160@j33g2000cwa.googlegroups.com>

This smells like a possible threading issue, where multiple threads are
accessing the same connection object.  Remember that the same HTTP
session can be accessed by multiple threads concurrently, and the
PostgreSQL JDBC driver is not thread-safe.

To see if this is the case, try adding some additional synchronization
to guarantee that no two threads will use the connection at the same
time (perhaps by synchronizing on the Connection object).

-- Mark

On Wed, 2006-04-12 at 08:41 -0700, kevin@mtel.co.uk wrote:
> i read in the posts here that postgres 8.0 jdbc had unmasked it;s
> dislike of changing transaction level mid transaction so i changed my
> code to the following
> 
> is this set up correct?
> 
>         try {
>             livedb.setAutoCommit(false);
>             copydb.setAutoCommit(false);
> 
> 
> livedb.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
> 
>             copydb.setTransactionIsolation
> (Connection.TRANSACTION_SERIALIZABLE);
> 
>             // series of writes to both db's
> 
>             livedb.commit();
>             livedb.setAutoCommit(true);
>             copydb.commit();
>             copydb.setAutoCommit(true);
> 
>         } catch (SQLException sqle){
>                 // run a rollback-Release and log it routine;
> 
>                 // crash and burn;
>         }
> 
> this seems to work fine single user, but with several users on i get
> occasional dumps with
> transaction change in transaction.
> 
> the only code to change relates to the LUW start since the last rollout
> of this servlet and there was never this problem before.
> the connections are stored as a session attribute, so persist across
> requests.
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
> 
>                http://www.postgresql.org/docs/faq



view thread (3+ messages)  latest in thread

Message-ID: <1144859893.5541.246.camel@archimedes>
Permalink:  ../1144859893.5541.246.camel@archimedes/
Also on:    postgresql.org/message-id/1144859893.5541.246.camel@archimedes

 · 

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: mark.lewis@mir3.com, kevin@mtel.co.uk
  Subject: Re: postgres jdbc transaction problem surfaces at times
  In-Reply-To: <1144859893.5541.246.camel@archimedes>
  References: <1144856469.014948.89160@j33g2000cwa.googlegroups.com> <1144859893.5541.246.camel@archimedes>

* 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