Обсуждение: XADataSource interface

Поиск
Список
Период
Сортировка

XADataSource interface

От
Heikki Linnakangas
Дата:
Hello,

I posted an updated version of the XADataSource implementation few weeks
ago, but haven't received any comments:

http://archives.postgresql.org/pgsql-jdbc/2005-09/msg00131.php

Has anybody looked at it yet?

- Heikki

Re: XADataSource interface

От
Dave Cramer
Дата:
Heikki,

I will look at this shortly, is this a diff from a relatively current
HEAD ?

Dave
On 25-Oct-05, at 1:01 PM, Heikki Linnakangas wrote:

> Hello,
>
> I posted an updated version of the XADataSource implementation few
> weeks ago, but haven't received any comments:
>
> http://archives.postgresql.org/pgsql-jdbc/2005-09/msg00131.php
>
> Has anybody looked at it yet?
>
> - Heikki
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>               http://archives.postgresql.org
>
>


Re: XADataSource interface

От
Heikki Linnakangas
Дата:
Thanks. Yes, it's a diff from HEAD. Just checked, it still applies
cleanly.

It only modifies build.xml, everything else is in new files, so it
shouldn't bit rot easily anyway.

On Wed, 26 Oct 2005, Dave Cramer wrote:

> Heikki,
>
> I will look at this shortly, is this a diff from a relatively current HEAD ?
>
> Dave
> On 25-Oct-05, at 1:01 PM, Heikki Linnakangas wrote:
>
>> Hello,
>>
>> I posted an updated version of the XADataSource implementation few weeks
>> ago, but haven't received any comments:
>>
>> http://archives.postgresql.org/pgsql-jdbc/2005-09/msg00131.php
>>
>> Has anybody looked at it yet?
>>
>> - Heikki
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 4: Have you searched our list archives?
>>
>>               http://archives.postgresql.org
>>
>>
>
>

- Heikki

Re: XADataSource interface

От
Kris Jurka
Дата:

On Tue, 25 Oct 2005, Heikki Linnakangas wrote:

> I posted an updated version of the XADataSource implementation few weeks ago,
> but haven't received any comments:
>

Dave has committed this and I've made some further integration fixes to
it, but some of the tests you've provided fail with the attached errors.
I don't know much about XA, so I wanted to run some potential fixes by you
guys first.  Thoughts?

Kris Jurka

Вложения

Re: XADataSource interface

От
Heikki Linnakangas
Дата:
On Sat, 29 Oct 2005, Kris Jurka wrote:

> On Tue, 25 Oct 2005, Heikki Linnakangas wrote:
>
>> I posted an updated version of the XADataSource implementation few weeks
>> ago, but haven't received any comments:
>>
>
> Dave has committed this and I've made some further integration fixes to it,
> but some of the tests you've provided fail with the attached errors. I don't
> know much about XA, so I wanted to run some potential fixes by you guys
> first.  Thoughts?

It seems I forgot to run the tests myself before submitting, sorry about
that...

The test failure at testOnePhase was caused by the inverted equals test
you already noticed and fixed in your patch.

The failures at testRecover and testRollback were because
PGXAConnection.rollback method called Xid.equals with null argument.
I added a null-check for that, see attached patch.

I didn't understand this part of your patch:

--------------------------------------------------------------------------
diff -c -r1.2 PGXAConnection.java
*** org/postgresql/xa/PGXAConnection.java       29 Oct 2005 18:59:39 -0000
1.2
--- org/postgresql/xa/PGXAConnection.java       29 Oct 2005 19:05:09 -0000
***************
*** 172,178 ****
               throw new PGXAException(GT.tr("Prepare called before end"),
XAException.XAER_INVAL);

           state = STATE_IDLE;
!         currentXid = null;

           if (!conn.haveMinimumServerVersion("8.1"))
               throw new PGXAException(GT.tr("Server versions prior to 8.1
do not support two-phase
commit."), XAException.XAER_RMERR);
--- 172,178 ----
               throw new PGXAException(GT.tr("Prepare called before end"),
XAException.XAER_INVAL);

           state = STATE_IDLE;
! //        currentXid = null;

           if (!conn.haveMinimumServerVersion("8.1"))
               throw new PGXAException(GT.tr("Server versions prior to 8.1
do not support two-phase
commit."), XAException.XAER_RMERR);
--------------------------------------------------------------------------

Why is that? It looks wrong to me.

- Heikki

Вложения

Re: XADataSource interface

От
Heikki Linnakangas
Дата:
On Sun, 30 Oct 2005, Chris Smith wrote:

> Heikki Linnakangas wrote:
>> The failures at testRecover and testRollback were because
>> PGXAConnection.rollback method called Xid.equals with null argument.
>> I added a null-check for that, see attached patch.
>
> I didn't look too closely at the patch... but the API docs for Object.equals
> say clearly that this shouldn't be a problem.  For any non-null reference x,
> x.equals(null) should evaluate to false.  I suspect that the correct solution
> to this problem is to fix the implementation of equals, and not to add a
> check against null where you did.

True. However, since the object is supplied by the transaction manager
implementation, which we have no control over, I'd say it's better to
not make any assumptions about it that we don't have to.

- Heikki

Re: XADataSource interface

От
Kris Jurka
Дата:

On Sun, 30 Oct 2005, Heikki Linnakangas wrote:

> The failures at testRecover and testRollback were because
> PGXAConnection.rollback method called Xid.equals with null argument.
> I added a null-check for that, see attached patch.

Applied.  I'll put out a new dev release with the xa patches later
tonight.  Can you clarify what does/doesn't work in xa for the docs?

> I didn't understand this part of your patch:
>

Well, that's why I emailed you guys.  I was initially thinking that the
currentXid shouldn't be disassociated from the xaconnection until a new
transaction was actually started and it could simply commit/rollback the
underlying connection if a new one wasn't started.  I see that's not the
case now.

Kris Jurka

Re: XADataSource interface

От
Heikki Linnakangas
Дата:
On Mon, 31 Oct 2005, Kris Jurka wrote:

>
>
> On Sun, 30 Oct 2005, Heikki Linnakangas wrote:
>
>> The failures at testRecover and testRollback were because
>> PGXAConnection.rollback method called Xid.equals with null argument.
>> I added a null-check for that, see attached patch.
>
> Applied.  I'll put out a new dev release with the xa patches later tonight.
> Can you clarify what does/doesn't work in xa for the docs?

Thanks!

English is not my native language, so please check spelling:

"
The JTA specification requires an XADataSource implementation to
support transaction interleaving (see JTA spec section 3.4.4). However,
since PostgreSQL server doesn't support it natively, the JDBC driver
cannot support it either. The same goes for suspend/resume.

In practice, transaction managers don't need transaction interleaving or
suspend/resume to function correctly. Some commercial databases
also don't implement them natively, but emulate them in the JDBC driver.
That's error prone; PostgreSQL driver will throw an XAException instead.
"

The docs should also include instructions for using the XADataSource.
Example configurations for various application servers would be a nice
too.

- Heikki