Re: Re: [pgjdbc] XADataSource support for resource sharing & interleaving. (#47)

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: PostgreSQL JDBC <pgsql-jdbc(at)postgresql(dot)org>
Cc: Dave Cramer <pg(at)fastcrypt(dot)com>
Subject: Re: Re: [pgjdbc] XADataSource support for resource sharing & interleaving. (#47)
Date: 2013-03-19 11:48:10
Message-ID: 5148507A.1030000@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On 03/16/2013 01:14 AM, Dave Cramer wrote:
> I'm looking for opinions on this patch.
>
> On Fri, Mar 15, 2013 at 12:45 PM, Bryan Varner
> <notifications(at)github(dot)com <mailto:notifications(at)github(dot)com>> wrote:
>
> The support for interleaving and sharing is implemented by
> (potentially, only when needed) returning 'logical' connections
> from the XADataSource, and opening new physical connections to the
> backend server (when necessary) to handle [performing] work on
> behalf of a global TX or local TX.
>
This sounds like you're essentially implementing a connection pool
inside PgJDBC to handle transaction suspend, interleave, etc. This has
generally been recognised as the only way to achieve these features on
most real-world database products, so I don't have a problem with that
so long as it's set up and torn down properly, avoids resource leaks,
etc. I haven't taken a proper look at the code yet so I'm asking to help
me understand what I should be looking for.

Since JTA and the X/Open XA spec it is based on rather unfortunately
specifies transaction suspend and interleave as required features it was
always going to be necessary to do something awful like this at some
level. I thought that JBoss AS 7's JTA implementation took care of this
behind the scenes in cases where the JDBC driver didn't support tx
suspend and resume, though? Is that not the case? Do other XA clients
not do the same thing?

(Looks at some other project code)

Yep. I was using this with JTA, and JBoss AS 7 was taking care of all
the transaction suspend/interleave emulation its self:

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<datasource jndi-name="java:/datasources/XXXXXX" enabled="true"
use-java-context="true"
pool-name="XXXXX-pool">
<connection-url>jdbc:postgresql:XXXXX</connection-url>
<driver>postgresql-driver</driver>
<security>
<user-name>XXXXX</user-name>
<password>XXXXX</password>
</security>
</datasource>
</datasources>

This isn't a good reason not to fix XADataSource, but it might be
informative. If nothing else you can probably learn more about the
JTA/XA requirements and tricks for interleaving, etc, from AS7's code.

I was not using 2PC and co-ordinating with other transaction managers,
so it's entirely possible this only works for the
one-datasource-per-XA-transaction case.

> The behavior of opening new physical backends (implementing
> interleaving) can be disabled by setting the XAAcquireTimeout = 0,
> in which case the behavior of the old XADataSource implementation
> is retained, with a minimal performance impact.
>
Great, we'll almost certainly need that since someone's certain to be
relying on it - intentionally or not - and unwilling/unable to change
their code or the library they're using.

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Bryan Varner 2013-03-19 20:19:20 Re: Re: [pgjdbc] XADataSource support for resource sharing & interleaving. (#47)
Previous Message Craig Ringer 2013-03-19 11:46:48 Re: Client Certificate Authentication