PostgreSQL XAResource & GlassFish 3.1.2.2 - Mailing list pgsql-jdbc

From Bryan Varner
Subject PostgreSQL XAResource & GlassFish 3.1.2.2
Date
Msg-id A2B35D2698B0C74F9B8333525E67ED0135F89007@plindyexch02.polarislabs.lan
Whole thread Raw
Responses Re: PostgreSQL XAResource & GlassFish 3.1.2.2
List pgsql-jdbc
Greetings all,

I'm having a nightmare of a time using the PGXADataSource in a production GlassFish environment. It worked fine our lower volume test environments.

Is anyone else using the XADataSource with GlassFish? How about other JEE containers?

The problems we're having seem to be specific to the XA implementation, or possibly the GlassFish connection pool.

Things I've tracked down so far:

  * 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.

 * 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.

It seems as though the PG XAResource implementation is a single-association implementation that will only work properly in a single-threaded environment. GlassFish appears to be expecting it to work as a multiple association (but without TX interleaving) resource. Am I missing some sort of magical configuration setting, or is this a known limitation (the whole single-threaded, non synchronized, and single-association) of the current driver?

Regards,
-Bryan Varner

pgsql-jdbc by date:

Previous
From: Guillaume Cottenceau
Date:
Subject: Re: RE: [JDBC] é converted iné
Next
From: Craig Ringer
Date:
Subject: Re: [HACKERS] JPA + enum == Exception