pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <hlinnakangas@vmware.com>
To: Bryan Varner <bvarner@polarislabs.com>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Re: PostgreSQL XAResource & GlassFish 3.1.2.2
Date: Tue, 12 Feb 2013 13:50:23 +0200
Message-ID: <511A2C7F.1040104@vmware.com> (raw)
In-Reply-To: <A2B35D2698B0C74F9B8333525E67ED0135F89007@plindyexch02.polarislabs.lan>
References: <A2B35D2698B0C74F9B8333525E67ED0135F89007@plindyexch02.polarislabs.lan>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

On 12.02.2013 05:36, Bryan Varner wrote:
>    * Race conditions as multiple threads are participating in the same transaction, invoking XAResource methods. Status checks in PGXAConnection.java are throwing exceptions (if state == ACTIVE) throw) by the time in invokes the throw, the state is != ACTIVE)  Before you start telling me I shouldn't be using threads in a  JEE environment let me remind you that EJBs by default are served out of thread pools, and allow for concurrent threads to participate within a single TX scope. This is outlined as part of the transaction context in the JTS spec (section 2.2 and 2.3) and synchronized thread-safe access to XAResources is described (without being explicitly called out) by the JTA 1.0.1 spec.

We could fairly easily just add "synchronized" to all the public 
methods. I wonder how sane it is for Glassfish to be doing that in the 
first place, though. AFAICS, in any combination of two XAResource 
methods, called concurrently, one of the threads will get an error 
anyway. For example, if two threads try to call start() at the same 
time, one of them has to fail because an XAResource can only be 
associated with a one transaction at a time.

>   * It appears that a second thread attempting to join an existing XAResource's scope with start(XID, TMJOIN) is going to be refused, even if it's attempting to participate in the same XID. The exception thrown is one complaining about interleaving, even though it's the -same- XID, not a sub-set of work in another TX.

Hmm, so the application server is trying to do something like this:

xares.start(1234, 0);
xares.start(1234, TMJOIN);

We could easily allow that in the driver (ie. do nothing), but that 
doesn't seem like valid sequence of calls to begin with. You must 
disassociate the XAResource from the current transaction with end(), 
before re-associating it with start().

If you have a simple stand-alone test application that reproduces the 
problems, I could take a closer look.

- Heikki


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



view thread (24+ messages)  latest in thread

Message-ID: <511A2C7F.1040104@vmware.com>
Permalink:  ../511A2C7F.1040104@vmware.com/
Also on:    postgresql.org/message-id/511A2C7F.1040104@vmware.com

 · 

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: hlinnakangas@vmware.com, bvarner@polarislabs.com
  Subject: Re: PostgreSQL XAResource & GlassFish 3.1.2.2
  In-Reply-To: <511A2C7F.1040104@vmware.com>
  References: <A2B35D2698B0C74F9B8333525E67ED0135F89007@plindyexch02.polarislabs.lan> <511A2C7F.1040104@vmware.com>

* 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