Biraja
Biraja

Reputation: 83

Issue integrating mariaDB client with MySQL DB

I am running a java application with MySQL as the DB server. DB is a AWS RDS. The MySQL connector is published under GNU/GPL so it has to be substituted with something more lenient. Maria DB client claimed to be compatible. But ever since MariaDB client is being used we are seeing the below intermittent issue during DB intensive activities:

Excption:-
SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/Projectname] threw exception [Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection] with root cause
java.sql.SQLNonTransientConnectionException: (conn=1530488) Connection is closed
    at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.createException(ExceptionFactory.java:73)
    at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.create(ExceptionFactory.java:187)
    at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.cmdPrologue(AbstractQueryProtocol.java:1940)

Caused by: org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
    at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:48)
    at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)

Caused by: java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=XXXXXXXXXX)(port=3306)(type=master) : (conn=1530487) could not load system variables
    at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.createException(ExceptionFactory.java:73)
    at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.create(ExceptionFactory.java:192)
    at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1372)

I have tried increasing the time_wait and max_allowed_packet to the maximum allowed but the issue still exists.

Versions:- MySQL - 5.7.26 MariaDB connector - 2.6.2

Upvotes: 2

Views: 3159

Answers (1)

mbourgon
mbourgon

Reputation: 1336

Just came across this, found an answer. On my side this was for an Aurora 1 MySQL DB (equiv to 5.6).

As per Diego Dupin in https://jira.mariadb.org/browse/CONJ-824:

only good solution is to use option `usePipelineAuth=false&useBatchMultiSend=false`

So your DB connection string might look like this: jdbc:mysql://127.0.0.1:3307/mydbname?usePipelineAuth=false&useBatchMultiSend=false

More details:

Aurora proxy has a known race condition issue that results in skipping other 
queries in proxy buffer. connection might be in hang waiting for query response. 
During authentication, socket has a timeout, that will result throwing the error 
you describe.

So if `usePipelineAuth` or `useBatchMultiSend` is enable, it might work ... or not. 
All pipeline options (`usePipelineAuth` and `useBatchMultiSend`) must be disabled when using aurora. 
Problem has been reported to aurora a few times without correction.

Upvotes: 6

Related Questions