Description:
Currently, the static hash map in MysqlXAConnection is populated as such:
HashMap temp = new HashMap();
temp.put(Constants.integerValueOf(1397), Constants.integerValueOf(XAException.XAER_NOTA));
temp.put(Constants.integerValueOf(1398), Constants.integerValueOf(XAException.XAER_INVAL));
temp.put(Constants.integerValueOf(1399), Constants.integerValueOf(XAException.XAER_RMFAIL));
temp.put(Constants.integerValueOf(1400), Constants.integerValueOf(XAException.XAER_OUTSIDE));
temp.put(Constants.integerValueOf(1401), Constants.integerValueOf(XAException.XAER_RMERR));
temp.put(Constants.integerValueOf(1402), Constants.integerValueOf(XAException.XA_RBROLLBACK));
MYSQL_ERROR_CODES_TO_XA_ERROR_CODES = Collections.unmodifiableMap(temp);
This is missing XA error codes that can be sent from the server as detailed in: http://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
Specifically:
Error: 1440 SQLSTATE: XAE08 (ER_XAER_DUPID)
Error: 1613 SQLSTATE: XA106 (ER_XA_RBTIMEOUT)
Error: 1614 SQLSTATE: XA102 (ER_XA_RBDEADLOCK)
How to repeat:
Transaction managers need the XA error code to determine what action to take and right now, when there is a deadlock, they don't and report that the exception is an unknown error:
ARJUNA16045: attempted rollback of < formatId=131076, gtrid_length=29, bqual_length=28, tx_uid=0:ffff0a2c2311:983f:4f287b38:176, node_name=1, branch_uid=0:ffff0a2c2311:983f:4f287b38:179, eis_name=unknown eis name > (com.mysql.jdbc.jdbc2.optional.JDBC4MysqlXAConnection@258bd34e) failed with exception code Unknown error code:0
com.mysql.jdbc.jdbc2.optional.MysqlXAException: XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected
Note the text "Unknown error code:0"
The correct behavior here should be error code: 102.
Suggested fix:
The hashmap needs to include:
temp.put(Constants.integerValueOf(1440), Constants.integerValueOf(XAException.XAER_DUPID));
temp.put(Constants.integerValueOf(1613), Constants.integerValueOf(XAException.XA_RBTIMEOUT));
temp.put(Constants.integerValueOf(1614), Constants.integerValueOf(XAException.XA_RBDEADLOCK));