Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UHv1o-00049g-GZ for pgsql-jdbc@arkaria.postgresql.org; Tue, 19 Mar 2013 11:48:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UHv1o-0006wL-1R for pgsql-jdbc@arkaria.postgresql.org; Tue, 19 Mar 2013 11:48:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UHv1n-0006wG-BK for pgsql-jdbc@postgresql.org; Tue, 19 Mar 2013 11:48:27 +0000 Received: from outmail148154.authsmtp.co.uk ([62.13.148.154]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UHv1i-00036o-Hx for pgsql-jdbc@postgresql.org; Tue, 19 Mar 2013 11:48:27 +0000 Received: from mail-c233.authsmtp.com (mail-c233.authsmtp.com [62.13.128.233]) by punt6.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id r2JBmJu7099622; Tue, 19 Mar 2013 11:48:19 GMT Received: from ayaki.localdomain (124-169-167-240.dyn.iinet.net.au [124.169.167.240]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/) with ESMTP id r2JBmAqm092338 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Tue, 19 Mar 2013 11:48:15 GMT Message-ID: <5148507A.1030000@2ndquadrant.com> Date: Tue, 19 Mar 2013 19:48:10 +0800 From: Craig Ringer Organization: 2nd Quadrant User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130219 Thunderbird/17.0.3 MIME-Version: 1.0 To: PostgreSQL JDBC CC: Dave Cramer Subject: Re: Re: [pgjdbc] XADataSource support for resource sharing & interleaving. (#47) References: In-Reply-To: X-Enigmail-Version: 1.5.1 Content-Type: multipart/alternative; boundary="------------060600000900060703020909" X-Server-Quench: e352c83b-908a-11e2-a49c-0025907707a1 X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCdxZQATClZeVg0b BQteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksadBtFaQxbYFhD HGQLWldEUVx7XWt/ agwfbAdZfEtIVhtr Vk9XQFZSCwdtAxke B1BcUGMAKnQHJX55 Z0VhVj5ZW0B5dwgo QUtWRmUFN3ppaGhO TUFZIgFJIQdDLQJF alJ6XXMKZmUAN3su JQJhdwMTER90HWxv T1NFHkodQ0oBFQt0 dzkuFCkmJkoYXS4+ Zwc7MkYbBlpZPEIo eUEsQlUFKRQfQhZe FltMBiA7bxdJRiw3 ABleUEcAETtSB28c SUF3Y3cA X-Authentic-SMTP: 61633235383639.1021:706 X-AuthFastPath: 0 (Was 255) X-AuthSMTP-Origin: 124.169.167.240/2525 X-AuthVirus-Status: No virus detected - but ensure you scan with your own anti-virus system. X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org This is a multi-part message in MIME format. --------------060600000900060703020909 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 > > 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: jdbc:postgresql:XXXXX postgresql-driver XXXXX XXXXX 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 --------------060600000900060703020909 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
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> 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
--------------060600000900060703020909--