Subject | problem with XAResource.TMJOIN |
---|---|
Author | Ludovic Orban |
Post date | 2005-10-28T14:30:20Z |
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(FBManagedConnection.java:1069)
at
org.firebirdsql.jca.FBManagedConnection.internalStart(FBManagedConnection.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.
The second check will be incorrectly successful if you connect to 2
different databases with the same driver like my case.
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
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(FBManagedConnection.java:1069)
at
org.firebirdsql.jca.FBManagedConnection.internalStart(FBManagedConnection.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.
The second check will be incorrectly successful if you connect to 2
different databases with the same driver like my case.
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