java - mariadb 中废弃的连接清理(与 mysql 相比)?

标签 java mysql mariadb

mysql-connector 切换到 mariadb 客户端库:

mysql 类 com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.checkedShutdown() 的等价物是什么?

如果有的话? (我也在使用 hikari 连接池)。

最佳答案

我不相信有等效项,看起来这个功能没有迁移到 Maria DB。更谨慎的做法是在应用程序中修复连接泄漏。

正如 HikariCP 池作者在 this message 中所解释的那样,这个强制关闭废弃连接的特性有很多问题:

Yes, we have considered it (removing abandoned connections), but ultimately we decided to pass. The problem with closing leaked connections is several fold. Some thread is possibly using that connection, and its going to blow-up (in production) somewhere if we close it. Or nothing is using that connection, and closing it has no negative impact, but now we've just covered up a leak that will cause constant cycling of connections in the pool.

Applications are responsible for cleaning up resources. Java developers tend to get lazy compared to C/C++ programmers. This is leak just like a memory leak, and both can and rightfully should eventually kill your application. How else would you 1) know a problem exist, and 2) be motivated to track it down and fix it.

We do appreciate all input, even if not adopted. In this case, users looking for a library to defensively cover-up coding errors should probably look to tomcat-jdbc.

Note, leak detection can be run in production, and can be enabled at runtime through a JMX console, so there's not a lot of justification for adding proactive connection reclamation.

关于java - mariadb 中废弃的连接清理(与 mysql 相比)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53187716/

相关文章:

php - Laravel - MariaDB 服务器版本,可在附近使用正确的语法

java - 使用 typeliteral 在 guice 中注入(inject)泛型,但 typeliteral 构造函数受到保护

javascript - 使用 JQUERY 更新 Mysql

mysql - Manjaro Linux 中 MySQL 的外键格式错误

MySQL 外键约束的形成不正确

php - 使用在单独函数中创建的字符串插入到表中

hibernate - 使用 MetadataBuilderContributor 添加对 "match against" hibernate 的支持

java - 限制自定义基本类型的接口(interface)大小,以便实现自定义类型遵循它

java.lang.NoClassDefFoundError : Could not initialize class com. amazonaws.ClientConfiguration

java - 构建问题 Spring 3 -hibernate 3 项目