Mysql grails 应用程序连接超时,在 ELB 上使用 mariadb galera 集群

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

我最近刚刚将我的数据库从 mysql 迁移到 mariadb,以支持使用 2 节点集群数据库进行复制。数据库托管在不同的域上并通过 ELB 访问,当我将我的应用程序指向其中一个节点时,应用程序工作正常但是当我使用 ELB url 连接数据库时,它随机波动并且频繁显示后续错误

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

这是我的数据源配置:-

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
}

谁能找出问题所在并提供可能的解决方案

我发现了问题,在 ELB 中有一个名为 idleTimeOut 的字段被设置为仅 60 秒,花费超过 1 分钟的查询意外下降,将超时增加到 600 秒后问题就没有了复制了。 :)