[
https://issues.apache.org/jira/browse/DERBY-2220?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12466760
]
Julius Stroffek commented on DERBY-2220:
----------------------------------------
I spent more time trying to dig out something... There is a good description
about the derby implementation in the source of
org.apache.derby.iapi.jdbc.ResourceAdapter interface.
There exist a 1:1 mapping between XAConnection instance and XAResource instance.
The behaviour how the driver should behave if the connection willl be closed is
not covered by the JTA specification at all. The XAResource could be in the
following states:
* Not Associated with global transaction
* Associated with global transaction
* Association Suspended
According the JTA Specification if the transaction is suspended, it have to be
only resumed, finished with success or error on the same XAResource instance.
At least transaction association table shows that the XAResource instance could
not be used for something else than calling end(TMRESUME), end(TMFAIL) and
end(TMSUCCESS). I found somewhere in code that the derby implements this in the
same way (can not find the comment again, still trying ;-).
It seems that it should be fairly easy and safe to roll back an XA transaction
when the logicall connection will be closed by the client and the transaction
was in Associated state on that connection.
However, there is still the case when all the transaction branches are
dissassociated from the connections but the application had not done commit or
roll back yet and will never do that in the future (wrong code, or application
crash). It seems to me that the only one solution to this is to implement some
sort of configurable time out for inactivity for global transaction on
XAResource instances. Any other suggestions?
> Uncommitted transactions executed throught XAResource will held locks after
> the application terminates (or crashes during the transaction).
> -------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-2220
> URL: https://issues.apache.org/jira/browse/DERBY-2220
> Project: Derby
> Issue Type: Bug
> Affects Versions: 10.3.0.0
> Environment: Solaris Nevada build 49, Sun's JDK1.6
> Reporter: Julius Stroffek
> Assigned To: Julius Stroffek
> Attachments: XATranTest.java, xxx.sql
>
>
> Using this piece of code derby will not release a table lock of 'dummy' table.
> String query = "insert into dummy (field1) values ('" +
> Integer.toString(value) + "')";
> XAConnection xaConnection =
> createXAConnection("jdbc:derby://localhost:1527/TestDB", "", "");
> XAResource xaResource = xaConnection.getXAResource();
> conn = xaConnection.getConnection();
>
> Xid xid = createXid(value);
> xaResource.setTransactionTimeout(10);
> xaResource.start(xid, XAResource.TMNOFLAGS);
>
> Statement statement = conn.createStatement();
> statement.execute(query);
>
> // terminate the client application
> // this will not release any locks
> System.exit(0);
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.