db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel John Debrunner (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-2360) The XAResource.end(xid, XAResource.TMFAIL) throws an exception
Date Thu, 01 Mar 2007 16:39:51 GMT

    [ https://issues.apache.org/jira/browse/DERBY-2360?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12477028
] 

Daniel John Debrunner commented on DERBY-2360:
----------------------------------------------

XAExceptions are how XA return codes are returned.

A valid state change on an xa_end is from active (S1) to rollback-only (S4), this is from
table 6-4 in the XA spec [page 62 (75 in pdf)].

This state change can occur on any xa_end, *even one* that passes in TMSUCCESS.
With XAResource.end() being void, how else can a resource manager indicate to the transaction
manager that an end(TMSUCCESS) has failed and changed the transaction state to S4 rollback
only?

Transaction managers need to handle this, it's not Derby's problem that Geronimo  and JOTM
are implemented incorrectly.

Now the text of the description of TMFAIL from the XA spec is interesting. (see quote above).
It says for an xa_end(TMFAIL)

The transaction manager (app-server) *will* mark the global transaction as rollback only.

The resource manager (derby) *may also choose* to mark the transaction as rollback only.
If it (derby) does so then xa_end returns an RB errorcode.

Derby implents this last portion by choosing to mark the transaction as rollback only and
thus according to the spec has to return
an RB error code and so does so through the only mechanism available, XAException.

> The XAResource.end(xid, XAResource.TMFAIL) throws an exception
> --------------------------------------------------------------
>
>                 Key: DERBY-2360
>                 URL: https://issues.apache.org/jira/browse/DERBY-2360
>             Project: Derby
>          Issue Type: Bug
>    Affects Versions: 10.3.0.0
>         Environment: Solaris Nevada build 56, sun jdk 1.6
>            Reporter: Julius Stroffek
>         Assigned To: Julius Stroffek
>
> If I execute this peace of code
>         Xid xid = createXid(9,11);
>         xaRes.start(xid, XAResource.TMNOFLAGS);
>         Statement stm = conn.createStatement();
>         stm.execute("create table NumberTable2 (i int)");
>         stm.execute("insert into NumberTable2 values (1)");
>         xaRes.end(xid, XAResource.TMFAIL);
>         xaRes.rollback(xid);
> I get the following exception
> 1) testXAConnection(org.apache.derbyTesting.functionTests.tests.jdbcapi.XATransactionTest)javax.transaction.xa.XAException
>         at org.apache.derby.jdbc.EmbedXAResource.end(EmbedXAResource.java:208)
>         at org.apache.derbyTesting.functionTests.tests.jdbcapi.XATransactionTest.testXAConnection(XATransactionTest.java:94)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:76)
>         at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
>         at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
>         at junit.extensions.TestSetup.run(TestSetup.java:25)
>         at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
>         at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
>         at junit.extensions.TestSetup.run(TestSetup.java:25)
>  
> If I change TMFAIL to TMSUCCESS, everything works. The end with TMFAIL shoudl do the
same as with TMSUCCESS except that I can only rollback the transaction.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message