Skip to content

JDBC Driver still throwing XAException with error code XAER_RMERR on AG failover. #2130

@djmatthews

Description

@djmatthews

Driver version

The JDBC driver version is 12.3.0 Preview Release

SQL Server version

SQL Server AG 2017

Client Operating System

Windows Server 2016, version 10.0

JAVA/JVM version

Java version = 1.8.0_171, Java Runtime Version = 8.0.5.17 - pxa6480sr5fp17ifix-20180726_01(SR5 FP17+IJ08001)

Table schema

Problem description

This is a follow on from #1432
Despite having the fix for 1432 (#2078) the same behaviour occurred ie the JDBC driver reported an XAER_RMERR when it should have reported an XAER_RMFAIL resulting in indoubt transactions remaining in SQLServer during failover from AG primary to secondary.

Expected behavior

JDBC driver should have thrown an XAException with errorCode XAER_RMFAIL

Actual behavior

JDBC driver throws XAException with errorCode XAER_RMERR

Error message/stack trace

Complete error message and stack trace.

Here is a callstack showing the XAException on the XA commit:

[5/15/23 20:05:33:883 UTC] 00000160 WSRdbXaResour < commit Exit
javax.transaction.xa.XAException: com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.dtc_XA_interface(SQLServerXAResource.java:773)
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.commit(SQLServerXAResource.java:839)
at com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl.commit(WSRdbXaResourceImpl.java:361)
at com.ibm.ejs.j2c.XATransactionWrapper.commit(XATransactionWrapper.java:496)
at com.ibm.tx.jta.impl.JTAXAResourceImpl.commit(JTAXAResourceImpl.java:308)
at com.ibm.tx.jta.impl.RegisteredResources.deliverOutcome(RegisteredResources.java:1644)
at com.ibm.tx.jta.impl.RegisteredResources.distributeOutcome(RegisteredResources.java:2003)
at com.ibm.tx.jta.impl.RegisteredResources.distributeCommit(RegisteredResources.java:2315)
at com.ibm.tx.jta.impl.TransactionImpl.internalCommit(TransactionImpl.java:1879)
at com.ibm.tx.jta.impl.TransactionImpl.internalCommit(TransactionImpl.java:1855)
at com.ibm.tx.jta.impl.TransactionImpl.coreStage2CommitProcessing(TransactionImpl.java:1135)
at com.ibm.tx.jta.impl.TransactionImpl.stage2CommitProcessing(TransactionImpl.java:1173)
at com.ibm.tx.jta.impl.TransactionImpl.processCommit(TransactionImpl.java:1034)
at com.ibm.tx.jta.impl.TransactionImpl.commit(TransactionImpl.java:964)
at com.ibm.ws.tx.jta.TranManagerImpl.commit(TranManagerImpl.java:439)
...
When the errorCode is checked:
[5/15/23 20:05:33:884 UTC] 00000160 RegisteredRes 3 XAException: error code XAER_RMERR

Any other details that can be helpful

Call stack in com.microsoft.sqlserver.jdbc.SQLServerXAResource shows that the driver contains the fix for issue 1432
It looks from the code change in the PR that the Exception handling to treat the error as an XAER_RMFAIL needs to include the case where the "Connection Reset" SQLServerException occurs. Moreover, I think it is arguable that by default the Exception handlilng should throw XAER_RMFAIL with XAER_RMERR only thrown if the specific error warrants it since XAER_RMERR is a much more specific error (with specific semantics in the XA Spec) than XAER_RMFAIL is - the JDBC driver code currently does the opposite (assuming that it will throw an XAER_RMERR unless the specifics of the error are determined to be XAER_RMFAIL).

JDBC trace logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionUsed when a question is asked, as opposed to an issue being raised

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions