为了账号安全,请及时绑定邮箱和手机立即绑定

HikariCP try-with-resources 连接泄漏

HikariCP try-with-resources 连接泄漏

慕雪6442864 2021-07-03 22:15:03
我正在做一些需要从 MariaDB 中提取数据(使用 HikariCP),然后通过 Redis 发送的工作。最终,当我尝试从数据库中提取时,连接将开始泄漏。这只会随着时间的推移而突然发生。这是泄漏开始发生时的完整日志:https : //hastebin.com/sekiximehe.makefile这是一些调试信息:21:04:40 [INFO] 21:04:40.680 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Before cleanup stats (total=6, active=2, idle=4, waiting=0)21:04:40 [INFO] 21:04:40.680 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - After cleanup  stats (total=6, active=2, idle=4, waiting=0)21:04:40 [INFO] 21:04:40.682 [HikariPool-1 connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.mariadb.jdbc.MariaDbConnection@4b7a5e9721:04:40 [INFO] 21:04:40.682 [HikariPool-1 connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - After adding stats (total=7, active=2, idle=5, waiting=0)21:05:05 [INFO] 21:05:05.323 [HikariPool-1 housekeeper] WARN  com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.mariadb.jdbc.MariaDbConnection@52ede989 on thread Thread-272, stack trace followsjava.lang.Exception: Apparent connection leak detected        at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:123)        at us.survivewith.bungee.database.FetchPlayerInfo.run(FetchPlayerInfo.java:29)        at java.lang.Thread.run(Thread.java:748)21:05:10 [INFO] 21:05:10.681 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Before cleanup stats (total=7, active=2, idle=5, waiting=0)21:05:10 [INFO] 21:05:10.681 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - After cleanup  stats (total=7, active=2, idle=5, waiting=0)
查看完整描述

2 回答

?
HUX布斯

TA贡献1876条经验 获得超6个赞

Jedis也是JedisPool的一个你应该关闭的资源:


 /// Jedis implements Closeable. Hence, the jedis instance will be auto-closed after the last statement.

 try (Jedis jedis = pool.getResource()) {


查看完整回答
反对 回复 2021-07-14
  • 2 回答
  • 0 关注
  • 546 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信