Bug #69506 XAER_DUPID error code is not returned when a duplicate XID is offered in Java
Submitted: 18 Jun 2013 19:55 Modified: 27 Sep 2013 16:19
Reporter: Tom Jenkinson Email Updates:
Status: Closed Impact on me:
Category:Connector / J Severity:S2 (Serious)
Version:5.1.22 OS:Linux (Fedora 18)
Assigned to: Filipe Silva CPU Architecture:Any
Tags: errorcode, java, xa, XAER_DUPID

[18 Jun 2013 19:55] Tom Jenkinson
When a second branch with a duplicate ID is attempted to be created on the same mysql server instance, mysql returns an XAException to Java with the stack trace:
com.mysql.jdbc.jdbc2.optional.MysqlXAException: XAER_DUPID: The XID already exists
	at com.mysql.jdbc.jdbc2.optional.MysqlXAConnection.mapXAExceptionFromSQLException(MysqlXAConnection.java:604)
	at com.mysql.jdbc.jdbc2.optional.MysqlXAConnection.dispatchCommand(MysqlXAConnection.java:583)
	at com.mysql.jdbc.jdbc2.optional.MysqlXAConnection.start(MysqlXAConnection.java:523)
	at MySQLDUPID.test(MySQLDUPID.java:48)

Unfortunately the XAException.errorCode returned is not equal to XAException.XAER_DUPID even though the text has correctly identified the scenario.

How to repeat:
Run the attached program.
[18 Jun 2013 19:57] Tom Jenkinson
A test case that illustrates the issue

Attachment: MySQLDUPID.java (text/x-java), 1.32 KiB.

[18 Jun 2013 22:17] Sveta Smirnova
Thank you for the report.

Verified as described.

But this is c/J issue: server returns correct error:

mysql> XA START 0x31,0x31,0x1;
ERROR 1440 (XAE08): XAER_DUPID: The XID already exists
[27 Sep 2013 16:19] Daniel So
Added the following entry to the Connector/J 5.1.27 changelog:

"When there was an attempt to create a second branch with a duplicate ID on the same MySQL server instance, the XAException.errorCode returned by Connector/J was not equal to XAException.XAER_DUPID."