pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <craig@2ndquadrant.com>
To: PostgreSQL JDBC <pgsql-jdbc@postgresql.org>
Cc: Dave Cramer <pg@fastcrypt.com>
Subject: Re: Re: [pgjdbc] XADataSource support for resource sharing & interleaving. (#47)
Date: Tue, 19 Mar 2013 19:48:10 +0800
Message-ID: <5148507A.1030000@2ndquadrant.com> (raw)
In-Reply-To: <CADK3HH+mSmgESAOXMcaOx2S60SBmegw9d7B_8qAw=Fkiin4ZaA@mail.gmail.com>
References: <CADK3HH+mSmgESAOXMcaOx2S60SBmegw9d7B_8qAw=Fkiin4ZaA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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@github.com <mailto:notifications@github.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

view thread (12+ messages)  latest in thread

Message-ID: <5148507A.1030000@2ndquadrant.com>
Permalink:  ../5148507A.1030000@2ndquadrant.com/
Also on:    postgresql.org/message-id/5148507A.1030000@2ndquadrant.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: craig@2ndquadrant.com, pg@fastcrypt.com
  Subject: Re: [pgjdbc] XADataSource support for resource sharing & interleaving. (#47)
  In-Reply-To: <5148507A.1030000@2ndquadrant.com>
  References: <CADK3HH+mSmgESAOXMcaOx2S60SBmegw9d7B_8qAw=Fkiin4ZaA@mail.gmail.com> <5148507A.1030000@2ndquadrant.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