Bug #13721 Connection failure after XA PREPARE rolls back global transaction
Submitted: 3 Oct 2005 18:03 Modified: 3 Oct 2005 18:07
Reporter: Mark Matthews Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.x OS:Any (Any)
Assigned to: Assigned Account CPU Architecture:Any

[3 Oct 2005 18:03] Mark Matthews
Description:
Serg, I know you know this is a known issue, but this bug is here for tracking purposes.

The issue (as you know) is that global transactions rollback on connection failure after "XA PREPARE", which means that a TM can't recover the them, and thus a violation of the XA protocol.

How to repeat:
The following test in JDBC fails with no XIDs returned for recovery (the .close() closes the _physical_ connection in this case):

public void testRecover() throws Exception {
		XAConnection xaConn = getXAConnection();
		
		Connection c = xaConn.getConnection();
		Xid xid = createXid();
		
		XAResource xaRes = xaConn.getXAResource();
		xaRes.start(xid, XAResource.TMNOFLAGS);
		c.createStatement().executeQuery("SELECT 1");
		xaRes.end(xid, XAResource.TMSUCCESS);
		xaRes.prepare(xid);
		xaConn.close();
		
		// Now try and recover
		XAResource recoverRes = getXAConnection().getXAResource();
		
		Xid[] recoveredXids = recoverRes.recover(XAResource.TMNOFLAGS);
		
		assertEquals(1, recoveredXids.length);
	}
[3 Oct 2005 18:07] Mark Matthews
Dupe of http://bugs.mysql.com/bug.php?id=12161