HikariCP maxLifeTime
来源:互联网 发布:windows xp 截图工具 编辑:程序博客网 时间:2024/06/07 15:09
WARN com.zaxxer.hikari.HikariConfig - maxLifetime is less than 120000ms, using default 1800000ms.
i don’t know your HikariCP Version, but in the version 2.2.4 you will find the reason why it will throw the above warning.
HikariConfig.class
(in the com.zaxxer.hikari.HikariConfig
):
private void More ...validateNumerics() { Logger logger = LoggerFactory.getLogger(getClass()); if (connectionTimeout == Integer.MAX_VALUE) { logger.warn("No connection wait timeout is set, this might cause an infinite wait."); } if (minIdle < 0 || minIdle > maxPoolSize) { minIdle = maxPoolSize; } if (maxLifetime < 0) { logger.error("maxLifetime cannot be negative."); throw new IllegalArgumentException("maxLifetime cannot be negative."); } else if (maxLifetime > 0 && maxLifetime < TimeUnit.SECONDS.toMillis(120)) { logger.warn("maxLifetime is less than 120000ms, using default {}ms.", MAX_LIFETIME); maxLifetime = MAX_LIFETIME; } if (idleTimeout != 0 && idleTimeout < TimeUnit.SECONDS.toMillis(30)) { logger.warn("idleTimeout is less than 30000ms, using default {}ms.", IDLE_TIMEOUT); idleTimeout = IDLE_TIMEOUT; } else if (idleTimeout > maxLifetime && maxLifetime > 0) { logger.warn("idleTimeout is greater than maxLifetime, setting to maxLifetime."); idleTimeout = maxLifetime; }
from this code, the maxLifeTime is at least 120000ms, using default 1800000ms. so you can’t set the maxLifeTime to 30000ms(30*1000). I guess your HikariCP version is at least older than 2.2.4.
But when you find the latest HikariCP version 2.7.4. it said “We strongly recommend setting this value, and it should be at least 30 seconds less than any database or infrastructure imposed connection time limit.”
the same class HikariConfig.class:
private void validateNumerics() { if(this.maxLifetime != 0L && this.maxLifetime < TimeUnit.SECONDS.toMillis(30L)) { LOGGER.warn("{} - maxLifetime is less than 30000ms, setting to default {}ms.", this.poolName, Long.valueOf(MAX_LIFETIME)); this.maxLifetime = MAX_LIFETIME; } if(this.idleTimeout + TimeUnit.SECONDS.toMillis(1L) > this.maxLifetime && this.maxLifetime > 0L) { LOGGER.warn("{} - idleTimeout is close to or more than maxLifetime, disabling it.", this.poolName); this.idleTimeout = 0L; } if(this.idleTimeout != 0L && this.idleTimeout < TimeUnit.SECONDS.toMillis(10L)) { LOGGER.warn("{} - idleTimeout is less than 10000ms, setting to default {}ms.", this.poolName, Long.valueOf(IDLE_TIMEOUT)); this.idleTimeout = IDLE_TIMEOUT; } if(this.leakDetectionThreshold > 0L && !unitTest && (this.leakDetectionThreshold < TimeUnit.SECONDS.toMillis(2L) || this.leakDetectionThreshold > this.maxLifetime && this.maxLifetime > 0L)) { LOGGER.warn("{} - leakDetectionThreshold is less than 2000ms or more than maxLifetime, disabling it.", this.poolName); this.leakDetectionThreshold = 0L; } if(this.connectionTimeout < 250L) { LOGGER.warn("{} - connectionTimeout is less than 250ms, setting to {}ms.", this.poolName, Long.valueOf(CONNECTION_TIMEOUT)); this.connectionTimeout = CONNECTION_TIMEOUT; } if(this.validationTimeout < 250L) { LOGGER.warn("{} - validationTimeout is less than 250ms, setting to {}ms.", this.poolName, Long.valueOf(VALIDATION_TIMEOUT)); this.validationTimeout = VALIDATION_TIMEOUT; } if(this.maxPoolSize < 1) { this.maxPoolSize = this.minIdle <= 0?10:this.minIdle; } if(this.minIdle < 0 || this.minIdle > this.maxPoolSize) { this.minIdle = this.maxPoolSize; }}
from this code, the maxLifeTime has been updated to 30000ms at least in this version.
So now please update your HikariCP version to the latest version 2.7.4 if you want to set maxLifeTime to 30000ms.
But if you update your HikariCP version to 2.7.4, i also recommend you two points:
to set maxLifeTime value to be at least 30000ms.
to set maxLifeTime value few minute less than mysql’s wait_timeout(show variables like “%timeout%”) to avoid broken connection exception.
if you want to get more detail. please refer to my answer in the stackoverflow: https://stackoverflow.com/questions/28180562/hikaricp-and-maxlifetime/47694402#47694402
- HikariCP maxLifeTime
- HikariCP数据库连接池配置 idleTimeout 、maxLifeTime、maximumPoolSize
- HikariCP
- 了解HikariCP
- HikariCP logoJDBC 连接池 HikariCP
- c3p0 hikariCp 性能对比
- hikariCP连接池
- HikariCP-Fatal exception
- HiKariCP的数据源配置:
- HikariCP 配置详解
- HikariCP 整合spring
- HikariCP连接Trafodion样例
- hikaricp配置数据源
- HiKariCP数据库连接池
- HikariCP的编码设置
- HikariCP 连接池例子
- HikariCP 数据库连接池
- druid和HikariCP
- perceptron与多层网络
- 棋盘上的距离
- 实验四
- Web部署到Nginx后静态文件加载不正常(MIME TYPE问题)
- 开始写博客,开始新的学习方式
- HikariCP maxLifeTime
- 简单的angular过滤器
- RxJava(一:functional reactive programming)
- Angular模糊查询
- 负数的四则运算(重载运算符)
- strut2的ognl的s标签获取下拉框并选中
- Java 多线程设计模式之Guarded Suspension
- 1、一维条码
- Java| Java关键字-final,finalize,finally专题