Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql connection time out in grails application, using mariadb galera cluster over ELB

I just recently migrated my database to support replication with a 2 node cluster database from mysql to mariadb. The database are hosted over different domain and is accessed over a ELB, when I point my application to one of the node the application works fine but when I use the ELB url to connect with the database, it randomly fluctuates and frequently show the followint error

Communication Link Failure
could not execute query; nested exception is org.hibernate.exception.JDBCConnectionException: could not execute query

Here is my datasource configuration:-

dataSource {
shard = false
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
dbCreate = "update" // one of 'create', 'create-drop','update'

properties {
    initialSize=5
    maxActive=50
    minIdle=5
    maxIdle=25
    maxWait = 10000
    maxAge = 10 * 60000
    timeBetweenEvictionRunsMillis=5000
    minEvictableIdleTimeMillis=60000
    validationQuery="SELECT 1"
    validationInterval=15000
    testWhileIdle=true
    testOnBorrow=true
    testOnReturn=false
    jdbcInterceptors = "ConnectionState"
    defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}

Can anyone please identify whats wrong and provide a possible solution for it

like image 350
thickGlass Avatar asked Sep 26 '22 19:09

thickGlass


1 Answers

I figured out the issue, there was a field in ELB called idleTimeOut which was set to only 60 sec, and query which took more than 1 min was droping unexpectedly, after increasing the timeout to 600 sec the problem is not replicating anymore. :)

like image 109
thickGlass Avatar answered Sep 30 '22 07:09

thickGlass