tomcat启动 c3p0死锁 ,测试,预发布没问题,生产环境启动c3p0死锁

2020-02-11 18:55:50.449  WARN c     : com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@6a749e11 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
2020-02-11 18:55:50.452  WARN [C3P0PooledConnectionPoolManager[identityToken->1hge1bfa8eeb65muaq2al|45f13281]-AdminTaskTimer] c.m.v.a.ThreadPoolAsynchronousRunner     : com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@6a749e11 -- APPARENT DEADLOCK!!! Complete Status: 
    Managed Threads: 3
    Active Threads: 3
    Active Tasks: 
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@258e6714
            on thread: C3P0PooledConnectionPoolManager[identityToken->1hge1bfa8eeb65muaq2al|45f13281]-HelperThread-#0
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@6bc4e1a2
            on thread: C3P0PooledConnectionPoolManager[identityToken->1hge1bfa8eeb65muaq2al|45f13281]-HelperThread-#1
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@146123e0
            on thread: C3P0PooledConnectionPoolManager[identityToken->1hge1bfa8eeb65muaq2al|45f13281]-HelperThread-#2
    Pending Tasks: 
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@13c1fbf0
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@45a1985b
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@924a8bc
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@1447f45b
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@8c59358
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@41efa15b
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@6da29092
Pool thread stack traces:
    Thread[C3P0PooledConnectionPoolManager[identityToken->1hge1bfa8eeb65muaq2al|45f13281]-HelperThread-#1,5,main]
        java.net.SocketInputStream.socketRead0(Native Method)
        java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
        java.net.SocketInputStream.read(SocketInputStream.java:170)
        java.net.SocketInputStream.read(SocketInputStream.java:141)
        com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:100)
        com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:143)
        com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:173)
        com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2954)
        com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:560)
        com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1014)
        com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2255)
        com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2106)
        com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2090)
        com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:795)
        com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:44)
        sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
        com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:400)
        com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:327)
        com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175)
        com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
        com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
        com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
        com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1176)
        com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1163)
        com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1908)
        com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
    Thread[C3P0PooledConnectionPoolManager[identityToken->1hge1bfa8eeb65muaq2al|45f13281]-HelperThread-#0,5,main]

    <?xml version="1.0" encoding="UTF-8"?>

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">

<context:property-override location="classpath:config/properties/connection.properties" />        
<bean id="dataSource1" class="com.mchange.v2.c3p0.ComboPooledDataSource"/>
<bean id="dataSource101" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <!--preparedStatement 不会在数据库被 cached导致 连接数的被占用,checkoutOut的时候超时-->
    <property name="maxStatements" value="0"/>
</bean>

<bean id="dataSource2" class="com.mchange.v2.c3p0.ComboPooledDataSource"/>
<bean id="dataSource3" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <!--preparedStatement 不会在数据库被 cached导致 连接数的被占用,checkoutOut的时候超时-->
    <property name="maxStatements" value="0"/>
</bean>
<!-- define the SqlSessionFactory -->
<bean id="sessionFactory1" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource1"/>
    <property name="configLocation" value="classpath:config/mybatis/mybatis-Configuration.xml"/>
    <property name="mapperLocations">
        <array>
            <value>classpath*:mapper/*Mapper.xml</value>
        </array>
    </property>
</bean>
<bean id="sessionFactory101" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource101"/>
    <property name="configLocation" value="classpath:config/mybatis/mybatis-Configuration.xml"/>
    <property name="mapperLocations">
        <array>
            <value>classpath*:mapper/*Mapper.xml</value>
        </array>
    </property>
</bean>

<bean id="sessionFactory2" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource2"/>
    <property name="configLocation" value="classpath:config/mybatis/mybatis-Configuration.xml"/>
    <property name="mapperLocations">
        <array>
            <value>classpath*:mapper/*Mapper.xml</value>
        </array>
    </property>
</bean>

<bean name="transactionManager1" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">   
    <property name="dataSource" ref="dataSource1"/>
</bean>
<bean name="transactionManager101" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource101"/>
</bean>

<bean name="transactionManager2" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">   
    <property name="dataSource" ref="dataSource2"/>
</bean>

<tx:annotation-driven transaction-manager="transactionManager1" />
<tx:annotation-driven transaction-manager="transactionManager101" />
<tx:annotation-driven transaction-manager="transactionManager2" />

<!-- 开启AOP 如果pointcut指向 controller则需要在springmvc的配置文件中配置 -->   
<aop:aspectj-autoproxy/>

<tx:advice id="txAdvice" transaction-manager="transactionManager1">
    <tx:attributes>
       <tx:method name="get*" propagation="REQUIRED" read-only="true" />
       <tx:method name="del*" propagation="REQUIRED" />
       <tx:method name="save*" propagation="REQUIRED" />
       <tx:method name="update*" propagation="REQUIRED" />
    </tx:attributes>
</tx:advice>

<aop:config expose-proxy="true">
    <!-- 
        第一个*代表所有的返回值类型 
        第一个.代表子包
        第二个*代表所有的类
        第三个*代表类所有方法
        第一个..代表所有的参数
     -->
    <aop:pointcut id="txPointcut" expression="execution(* app.service..*.*(..))" />
    <!-- Advisor定义,切入点和通知分别为txPointcut、txAdvice -->
    <aop:advisor pointcut-ref="txPointcut" advice-ref="txAdvice"/>
</aop:config>

##DB config
dataSource1.driverClass=com.mysql.jdbc.Driver
dataSource1.jdbcUrl=url
dataSource1.user=
dataSource1.password=
dataSource1.testConnectionOnCheckout=true
dataSource1.maxPoolSize=200
dataSource1.minPoolSize=10
dataSource1.initialPoolSize=10
dataSource1.checkoutTimeout=30000
dataSource1.maxIdleTime=30
dataSource1.maxStatements=0
dataSource1.maxStatementsPerConnection=0

dataSource101.driverClass=com.mysql.jdbc.Driver
dataSource101.jdbcUrl=url
dataSource101.user=
dataSource101.password=
dataSource101.testConnectionOnCheckout=true
dataSource101.maxPoolSize=200
dataSource101.minPoolSize=10
dataSource101.initialPoolSize=10
dataSource101.checkoutTimeout=30000
dataSource101.maxIdleTime=30
dataSource101.maxStatements=0
dataSource101.maxStatementsPerConnection=0

dataSource2.driverClass=com.mysql.jdbc.Driver
dataSource2.jdbcUrl=jdbc:mysql://localhost:3306/aaa?useSSL=true&useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
dataSource2.user=
dataSource2.password=
dataSource2.testConnectionOnCheckout=true
dataSource2.maxPoolSize=200
dataSource2.minPoolSize=10
dataSource2.initialPoolSize=10
dataSource2.checkoutTimeout=30000
dataSource2.maxIdleTime=30
dataSource2.maxStatements=0
dataSource2.maxStatementsPerConnection=0

dataSource3.driverClass=com.mysql.jdbc.Driver
dataSource3.jdbcUrl=jdbc:mysql://localhost:3306/admin?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
dataSource3.user=
dataSource3.password=
dataSource3.testConnectionOnCheckout=true
dataSource3.maxPoolSize=10
dataSource3.minPoolSize=5
dataSource3.initialPoolSize=5
dataSource3.checkoutTimeout=30000
dataSource3.maxIdleTime=30
dataSource3.maxStatements=0
dataSource3.maxStatementsPerConnection=0

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐