We are migrating from the MySQL connector to the MariaDB connector. We are using Spring and the Bitronix transaction manager.
When we changed connector, we are facing several issues with transactions. Probably we have found the root cause: differences between handling joined transactions with MySQL and Maria, please see details below:
We are using this annotation on several places in the project:
@Transactional(propagation = Propagation.REQUIRES_NEW)
Here is the differences in implementation:
MySQL connector, MysqlXAConnection#isSameRM implementation:
if(xaresinstanceofMysqlXAConnection){
return this.underlyingConnection.isSameResource(((MysqlXAConnection)xares).underlyingConnection);
}
MariaDB connector, org.mariadb.jdbc.MariaXaResource#isSameRM implementation:
//Typicallyusedbytransactionmanagerto"join"transactions.Wedonotsupportjoins,
//soalwaysreturnfalse;
return false;
Is there someone who faced the same issue? How to handle it?
Our implementation:
/**
* Implementation of Audit Log which saves data using JPA in new transaction.
*/
public class JpaAudit implements AuditSPI {
@Autowired
private AuditlogRepository auditLogRepository;
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void log(AuditLogEntity aAuditObj) {
auditLogRepository.save(aAuditObj);
}
}
Changing Propagation.REQUIRES_NEW to Propagation.REQUIRED helps but I think it is not way for us.