0

I setted below properties cause MySQL bug(https://www.atomikos.com/Documentation/KnownProblems#MySQL_XA_bug)

com.atomikos.icatch.serial_jta_transactions=false
pinGlobalTxToPhysicalConnection="true"

but when i test it with multiple request after upper properties set, it shows below error

XA resource 'shard0': suspend for XID '3139322E3136382E3231392E3131382E746D313634343537333034393734363030303031:3139322E3136382E3231392E3131382E746D31' raised -5: invalid arguments were given for the XA operation java.sql.SQLException: XAER_INVAL: Invalid arguments (or unsupported command)
at com.atomikos.datasource.xa.XAResourceTransaction.xaSuspend(XAResourceTransaction.java:700) [7 skipped]
at com.atomikos.datasource.xa.session.BranchEnlistedStateHandler.transactionSuspended(BranchEnlistedStateHandler.java:94)
at com.atomikos.datasource.xa.session.TransactionContext.transactionSuspended(TransactionContext.java:94)
at com.atomikos.datasource.xa.session.SessionHandleState.notifyBeforeUse(SessionHandleState.java:165)
at com.atomikos.jdbc.AtomikosConnectionProxy.enlist(AtomikosConnectionProxy.java:207)
... 140 common frames omitted

I wonder why my application throws 'UnexpectedTransactionContextException' from below code even i setted all properties.

//BranchEnlistedStateHandler.java(Atomikos)
    TransactionContextStateHandler checkEnlistBeforeUse ( CompositeTransaction currentTx)
            throws InvalidSessionHandleStateException, UnexpectedTransactionContextException 
    {
        
        if ( currentTx == null || !currentTx.isSameTransaction ( ct ) ) {
            //OOPS! we are being used a different tx context than the one expected...
            
            //TODO check: what if subtransaction? Possible solution: ignore if serial_jta mode, error otherwise.
            
            String msg = "The connection/session object is already enlisted in a (different) transaction.";
            if ( LOGGER.isTraceEnabled() ) LOGGER.logTrace ( msg );
            throw new UnexpectedTransactionContextException();
        } 
        
        //tx context is still the same -> no change in state required
        return null;
    }java
clapmin
  • 51
  • 4

1 Answers1

0

It is too late but this might help someone:

Spring Boot 2.6.7

mysql-connector-java 8.0.29

According to the atomikos problems MySQL_XA_bug try to add following properties to spring boot.

spring.jta.atomikos.properties.serial-jta-transactions = false
spring.datasource.xa.properties.pinGlobalTxToPhysicalConnection = true
Andrei C.
  • 57
  • 3
  • 8