pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Allman <msa@allman.ms>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: jdbc xa support
Date: Thu, 21 Jul 2005 21:04:33 -0400 (EDT)
Message-ID: <20050721203342.W75792@yvyyl> (raw)
In-Reply-To: <Pine.OSF.4.61.0507212140250.34894@kosh.hut.fi>
References: <20050719193245.D20902@yvyyl>
	<E3F1D1B7-B41C-40C4-9621-60F96363A032@fastcrypt.com>
	<Pine.OSF.4.61.0507201916300.205200@kosh.hut.fi>
	<20050720211921.V54984@yvyyl>
	<Pine.OSF.4.61.0507212140250.34894@kosh.hut.fi>

Heikki,

Thanks for your feedback.  I am working on improvements and documentation. 
The rest of my response is below.

On Thu, 21 Jul 2005, Heikki Linnakangas wrote:

> Thanks.
>
> So far so good. You still have all the same tough issues ahead as I do, 
> though.
>
> I realize it's work in progress, but here's some comments in no particular 
> order:
>
> 1. To answer the question in the source code: PostgreSQL doesn't support 
> transaction timeouts

I figured.

> 2. Using prepared statements like "PREPARE TRANSACTION ?" won't work. You can 
> only use prepared statements for normal SELECT/UPDATE/DELETE commands.

Doesn't the driver support client side prepared statements?

> 3. How are you planning to handle transaction interleaving discussed in the 
> thread Dave mentioned?

I'm not.  PostgreSQL does not support this behavior, and I see no need to 
pretend it does.  I think the appropriate thing to do is throw an 
exception when the second start is called.

I have serious doubts that any SQL database in the world supports this 
behavior correctly.  If you know of one that does, I'd like to see its 
magic.

> 4. recover is broken because it ignores the flags argument. That's going to 
> cause an endless loop in the transaction manager when it tries to recover. 
> See this discussion: 
> http://forum.java.sun.com/thread.jspa?threadID=475468&messageID=2232566

That is problematic.  The API for recovery is stateful, and, IMHO, poorly 
designed.  If you look at the original DTP XA spec you'll see it makes 
much more sense.

I don't know what to do about this yet.

> 5. commit and rollback check that the transaction is found in
> XID_TO_TRANSACTION_STATE_MAP. However, after a crash/recover cycle, the map 
> will be empty.

I think I have a good solution to this.  I'll post it with my next 
patchset, coming soon.  I'll elaborate then.

> 6. isSameRM considers two connections to the same database as different RMs. 
> I'm not sure what the implications of this are, but I feel that's not right. 
> I have the same issue in my implementation as well...

They're different RM's because you can't join a transaction across two 
physical JDBC Connections.  Each XAResource instance is associated with 
exactly one physical connection instance.

In light of the implementation, I could probably just define isSameRM() as 
return this == otherXAResource . . .

> Also take a look at a list of comments on my code by Mike Bonnet. Some of 
> them probably apply to your code as well. Those comments are about the 
> version that's on my pg webpage:
>
> http://users.tkk.fi/~hlinnaka/pgsql/

I saw these.  Nothing jumped out at me.  The documentation is inadequate, 
and I'll work on that.  The logging may be inadequate.  I don't know about 
that.  I've used this kind of XA implementation before and this kind of 
logging has been adequate for me to debug problems.

> The XA and JTA specifications are quite complicated. I'd like to see a good 
> set of test cases that exercise all possible scenarious and also error 
> conditions. We're also going to need testers with access to the popular 
> application servers so that we know our implementation works with them. 
> AFAIK, the only open source application server that does recovery properly is 
> the CVS head version of JOnAS.

I have some cactus test cases for an XML database that has an XA driver. 
I'm not feeling too motivated to port them to PostgreSQL.

> Also, if we violate some parts of the specs (like the transaction 
> interleaving part), it's important to know exactly what the limitations are 
> and why. I started to write down the exact preconditions for each method in 
> the javadoc comments, and also  separate which preconditions come from the 
> specs and which are just implementation-specific limitations.

I think the interleaving business is a non-issue.  I can't think of a real 
world case where a transaction manager would do this.  Can you?

Besides, like I said, I doubt any other SQL database supports this.  I 
know Berkeley DB does, but Berkeley DB lets you associate any database 
call with any transaction, so it's easy.

JTA was written with more than just SQL databases in mind, and I don't 
think we need to bend over backwards to implement some corner 
functionality for a resource which, by its design, doesn't support it.

Thanks again.  I'll post another revision which fixes recovery and 
addresses other issues soon.

Michael

> On Wed, 20 Jul 2005, Michael Allman wrote:
>
>> Here's my first cut:
>> 
>> http://www.allman.ms/pgjdbcxa/pgjdbcxa-20050720.jar
>> 
>> At this point I know the documentation is sparse.  I'll try to improve that 
>> situation soon.  Until then, I wanted to give everyone the opportunity to 
>> take a first look at the code and the approach.
>> 
>> I also have some questions, some of which are embedded in the .java files 
>> as comments.  If anyone has answers, please pass them along.
>> 
>> I'll let you chew on this and check back tomorrow.
>> 
>> Cheers,
>> 
>> Michael
>> 
>> On Wed, 20 Jul 2005, Heikki Linnakangas wrote:
>> 
>>> I'm working on it. Glad to hear your interested. I don't have much time to 
>>> work on it though, so I would be very happy if you took over.
>>> 
>>> I'll send you a copy of my workbench off-list so you can take a look. It's 
>>> work in progress, but I hope it helps..
>>> 
>>> I believe this is the discussion Dave mentioned:
>>> 
>>> http://archives.postgresql.org/pgsql-jdbc/2005-06/msg00165.php
>>> 
>>> - Heikki
>>> 
>>> On Tue, 19 Jul 2005, Dave Cramer wrote:
>>> 
>>>> Not sure, but look at the archives, there was some discussion about 
>>>> various mechanism.
>>>> 
>>>> Dave
>>>> On 19-Jul-05, at 7:34 PM, Michael Allman wrote:
>>>> 
>>>>> Hi,
>>>>> 
>>>>> I'm implementing XA support in the postgres JDBC driver to complement 
>>>>> the backend two phase commit support in CVS.  Is anyone else working on 
>>>>> this?
>>>>> 
>>>>> Michael
>>> 
>>> ---------------------------(end of broadcast)---------------------------
>>> TIP 4: Have you searched our list archives?
>>> 
>>>              http://archives.postgresql.org
>>> 
>> 
>
> - Heikki
>



view thread (27+ messages)  latest in thread

Message-ID: <20050721203342.W75792@yvyyl>
Permalink:  ../20050721203342.W75792@yvyyl/
Also on:    postgresql.org/message-id/20050721203342.W75792@yvyyl

 · 

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: msa@allman.ms, hlinnaka@iki.fi
  Subject: Re: jdbc xa support
  In-Reply-To: <20050721203342.W75792@yvyyl>
  References: <20050719193245.D20902@yvyyl> <E3F1D1B7-B41C-40C4-9621-60F96363A032@fastcrypt.com> <Pine.OSF.4.61.0507201916300.205200@kosh.hut.fi> <20050720211921.V54984@yvyyl> <Pine.OSF.4.61.0507212140250.34894@kosh.hut.fi> <20050721203342.W75792@yvyyl>

* 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