PostgreSQL XAResource & GlassFish 3.1.2.2

From: Bryan Varner <bvarner(at)polarislabs(dot)com>
To: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: PostgreSQL XAResource & GlassFish 3.1.2.2
Date: 2013-02-12 03:36:30
Message-ID: A2B35D2698B0C74F9B8333525E67ED0135F89007@plindyexch02.polarislabs.lan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Craig Ringer 2013-02-12 07:36:23 Re: [JDBC] JPA + enum == Exception
Previous Message Guillaume Cottenceau 2013-02-11 08:37:32 Re: RE: [JDBC] é converted in é