alibaba / druid

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

死锁问题咨询 #2400

Open VEMTK opened 6 years ago

VEMTK commented 6 years ago

@wenshao 您好,我这边一个项目在线上运行6个小时左右就会全部堵死在获取连接这,这个时候mysql运行情况一切正常,检测连接也没泄露,困扰了好久,能帮忙看下吗?

"http-apr-8808-exec-6278" #7591 daemon prio=5 os_prio=0 tid=0x00007f53dd935000 nid=0x7c75 waiting on condition [0x00007f530fcba000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method)

ydcun commented 6 years ago

能把你的配置参数贴出来看看嘛

在 2018年3月11日,22:53,vemtk notifications@github.com<mailto:notifications@github.com> 写道:

@wenshaohttps://github.com/wenshao 您好,我这边一个项目在线上运行6个小时左右就会全部堵死在获取连接这,这个时候mysql运行情况一切正常,检测连接也没泄露,困扰了好久,能帮忙看下吗?

"http-apr-8808-exec-6278" #7591 daemon prio=5 os_prio=0 tid=0x00007f53dd935000 nid=0x7c75 waiting on condition [0x00007f530fcba000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/alibaba/druid/issues/2400, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AEBoJ3PNp5RnH_vra62dzekQfmmL_4Onks5tdTpqgaJpZM4SluCV.

VEMTK commented 6 years ago
    <property name="initialSize" value="200"/>
    <!-- 连接池最大使用连接数量 -->
    <property name="maxActive" value="6000"/>
    <!-- 连接池最大空闲 -->
    <!-- <property name="maxIdle" value="2000" /> -->
    <!-- 连接池最小空闲 -->
    <property name="minIdle" value="1"/>

<!-- 配置获取连接等待超时的时间 -->
    <property name="maxWait" value="60000" />
    <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
    <property name="timeBetweenEvictionRunsMillis" value="60000" />
    <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
    <property name="minEvictableIdleTimeMillis" value="300000" />

    <!--
    <property name="poolPreparedStatements" value="false" />
    <property name="maxPoolPreparedStatementPerConnectionSize" value="33" />
    -->
    <property name="validationQuery" value="SELECT 'x'" />
    <property name="testOnBorrow" value="false"/>
    <property name="testOnReturn" value="false"/>
    <property name="testWhileIdle" value="true"/>

@ydcun

wenshao commented 6 years ago

如果一个请求需要两个以上连接,并发大于连接池maxSize,很容易到这这种情况

ydcun commented 6 years ago

你试试改下配置试试: minIdle设置的大点 100 添加下面的配置: removeAbandoned="true" removeAbandonedTimeout="200"