Subject Re: [Firebird-Java] problem with XAResource.TMJOIN
Author David Jencks
On Oct 28, 2005, at 7:30 AM, Ludovic Orban wrote:

> Hi,
>
> I think there is a nasty bug in the way Jaybird handles the
> XAResource.TMJOIN flag.
>
> When i try this code:
>
> boolean join = newXaRes.isSameRM(oldXaRes);
> if (join) newXaRes.start(oldXaResXid, XAResource.TMJOIN);
>
>
> I get this exception:
>
> org.firebirdsql.jca.FBXAException: You are trying to resume a
> transaction that has is new
>       at
>
> org.firebirdsql.jca.FBManagedConnection.findIscTrHandle(FBManagedConnec
> tion.java:1069)
>       at
>
> org.firebirdsql.jca.FBManagedConnection.internalStart(FBManagedConnecti
> on.java:995)
>       at
>
> org.firebirdsql.jca.FBManagedConnection.start(FBManagedConnection.java:
> 968)
>
>
> I think I found the cause of this problem:
>
> The 2 XAResources I try to join are both Firebird connections but to 2
> different databases, on the same machine with the same server but they
> could be on 2 different machines.
>
> XAResource.isSameRM() returns true in this case wich is incorrect. I
> looked at the code and in fact, it is mis-implemented.
>
> There is jsut a check that both XAResources are instance of class
> FBManagedConnection and that they have the same
> FBManagedConnectionFactory.
>
> The first check will fail incorrectly if a transaction manager stores
> the XAResource within a wrapper XAResource, like most do.

Umm, the wrapper had better implement isSameRM by asking the wrapped
resource. Otherwise you should expect really weird results. So, IMO
this argument is bogus.
>
> The second check will be incorrectly successful if you connect to 2
> different databases with the same driver like my case.

There is something wrong here, but it's not entirely clear to me where
the fault lies. If you are connecting to 2 databases, you should have
2 managed connection factories, and their properties should be
different, so mcf1.equals(mcf2) == false. I suspect you are creating
one MCF, getting a connection, changing the properties on the mcf, and
creating another connection. I think that's an error. However, since
you at least appear to have done this, it might be a good idea for
jaybird to extract the location of the db from the MCF and store it
with the MC for this purpose, as you suggest below.

thanks
david jencks

>
> By definition:
> "isSameRM is true if and only if both resources return the same set of
> XIDs as the result of calling recover()"
>
> but this definition causes a problem when both DB have no in-doubt
> transaction. I guess a check on the JDBC URL and/or the database
> property would be enough but I'm not sure.
>
> What should be done here ?
>
> Thanks,
> Ludovic
>
>
>
>
>
> SPONSORED LINKS
> Basic programming language
> Computer programming languages
> Programming languages
> Java programming language
>
> YAHOO! GROUPS LINKS
>
> ▪  Visit your group "Firebird-Java" on the web.
>  
> ▪  To unsubscribe from this group, send an email to:
>  Firebird-Java-unsubscribe@yahoogroups.com
>  
> ▪  Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service.
>
>