alibaba / druid

阿里云计算平台DataWorks(https://help.aliyun.com/document_detail/137663.html) 团队出品,为监控而生的数据库连接池
https://github.com/alibaba/druid/wiki
Apache License 2.0
27.95k stars 8.57k forks source link

疑似链接泄漏 #4675

Open zdtjss opened 2 years ago

zdtjss commented 2 years ago

应该是特定场景下导致的链接泄露,导致无法获取链接。用到连接池的地方只有mybatis、mybatis-plus、seata。一年内已经出现3次了,但无法定位到具体原因,求助。 版本:

com.alibaba druid-spring-boot-starter 1.1.22

MySQL驱动版本:8.0.22 seata版本:

io.seata seata-spring-boot-starter 1.3.0

mybatis-plus版本:

com.baomidou mybatis-plus-boot-starter 3.4.0

mybatis版本(没有单独引入):3.5.6 配置信息: initial-size: 10 max-active: 50 min-idle: 10 max-wait: 60000 pool-prepared-statements: true max-open-prepared-statements: 20 validation-query: Select 1 from DUAL test-on-borrow: true test-on-return: false test-while-idle: true logAbandoned: true removeAbandonedTimeoutMillis: 1800 time-between-eviction-runs-millis: 60000

@Configuration public class DataSourceConfig {

private final static Logger logger = LoggerFactory.getLogger(DataSourceConfig.class);

@Component("druidDataSource")
@ConfigurationProperties("spring.datasource.druid")
class DruidDataSourceWrapper extends DruidDataSource{

}

/**
 * init datasource proxy
 *
 * @Param: druidDataSource datasource bean instance
 * @Return: DataSourceProxy datasource proxy
 */
@Bean
@Primary
@DependsOn("druidDataSource")
public DataSourceProxy dataSource(DataSource druidDataSource) {
    logger.info("使用seata代理的数据源");
    return new DataSourceProxy(druidDataSource);
}

} 异常时堆信息: 微信图片_202202030020 微信截图_202202030023

zrlw commented 2 years ago

应该是shrink不应该采用System.arrayCopy前移方式清理connections数组的问题,和 #4692 应该是同一问题。