alibaba / druid

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

druid 1.2.8 connection reset #5068

Closed lineagezd closed 1 year ago

lineagezd commented 1 year ago

druid1.2.8 mybatis plus 3.4.2

异常信息:

Cause: java.sql.SQLNonTransientConnectionException: (conn=2829758) Connection reset

; (conn=2829758) Connection reset; nested exception is java.sql.SQLNonTransientConnectionException: (conn=2829758) Connection reset at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:81) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:88) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440) at com.sun.proxy.$Proxy189.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:223) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:173) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:78) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)

druid 配置如下: druid: #以下是全局默认值,可以全局更改

监控统计拦截的filters

    filters: stat
    initial-size: 10
    min-idle: 20
    max-active: 50
    max-wait: 60000
    max-idle: 30
    keep-alive: true
    keep-alive-between-time-millis: 45000
    time-between-eviction-runs-millis: 45000
    #一个连接在池中最小生存的时间
    min-evictable-idle-time-millis: 300000
    validation-query: SELECT 'x'
    test-while-idle: true
    test-on-borrow: false
    test-on-return: false
    pool-prepared-statements: false
    max-pool-prepared-statement-per-connection-size: 20
    remove-abandoned: false
    stat:
      merge-sql: false
      log-slow-sql: true
      slow-sql-millis: 30000
wenshao commented 1 year ago

链接断了

lineagezd commented 1 year ago

嗯,具体怎么排查有什么思路嘛

从抓包来看我们发现是物理主机主动发起了reset指令,主机和容器都做了抓包,看到reset报文是从主机测发起的,但不确定是什么原因

容器 -->主机--> 防火墙 --> 数据库(OceanBase)

kimmking commented 1 year ago

看起来是在连接创建或是使用后的60s内再使用时,服务器或路由/防火墙端主动断开了连接。

打开 testOnBorrow就成了。

superchangme commented 1 month ago

看起来是在连接创建或是使用后的60s内再使用时,服务器或路由/防火墙端主动断开了连接。

打开 testOnBorrow就成了。

不打开testOnBorrow就不能解决吗 官方不是默认为false吗