1
回答
c3p0死锁
科大讯飞通用文字识别100000次/天免费使用。立即申请   

通过c3p0连接mysql,远程连接的时候启动后第一次调用查询会报死锁错误,等自动解锁后就没有问题了,不知道什么原因求帮忙,本地连接就没有问题。试过网上很多方法也没有用。

错误日志如下:

[WARN ] 2017-08-30 11:21:41 com.mchange.v2.async.ThreadPoolAsynchronousRunner.(ThreadPoolAsynchronousRunner.java:759) - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@523f5df1 -- APPARENT DEADLOCK!!! Complete Status: 
    Managed Threads: 3
    Active Threads: 3
    Active Tasks: 
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@3ccb52c7
            on thread: C3P0PooledConnectionPoolManager[identityToken->1hge1389qdn08p6rqveaf|673cdf0c]-HelperThread-#1
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@48a7a5ff
            on thread: C3P0PooledConnectionPoolManager[identityToken->1hge1389qdn08p6rqveaf|673cdf0c]-HelperThread-#0
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@76832d9c
            on thread: C3P0PooledConnectionPoolManager[identityToken->1hge1389qdn08p6rqveaf|673cdf0c]-HelperThread-#2
    Pending Tasks: 
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@1e27998d
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@39d20772
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@be6eb06
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@654fdd04
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@5e376592
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@6ed8491
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@539a4f24
Pool thread stack traces:
    Thread[C3P0PooledConnectionPoolManager[identityToken->1hge1389qdn08p6rqveaf|673cdf0c]-HelperThread-#2,5,main]
        java.net.SocketInputStream.socketRead0(Native Method)
        java.net.SocketInputStream.read(SocketInputStream.java:152)
        java.net.SocketInputStream.read(SocketInputStream.java:122)
        com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)
        com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)
        com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
        com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2452)
        com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:591)
        com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1070)
        com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2048)
        com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:723)
        com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
        sun.reflect.GeneratedConstructorAccessor35.newInstance(Unknown Source)
        sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
        com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
        com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
        com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146)
        com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195)
        com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184)
        com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
        com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
        com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
        com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810)
        com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648)
    Thread[C3P0PooledConnectionPoolManager[identityToken->1hge1389qdn08p6rqveaf|673cdf0c]-HelperThread-#0,5,main]
        java.net.SocketInputStream.socketRead0(Native Method)
        java.net.SocketInputStream.read(SocketInputStream.java:152)
        java.net.SocketInputStream.read(SocketInputStream.java:122)
        com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)
        com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)
        com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
        com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2452)
        com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:591)
        com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1070)
        com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2048)
        com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:723)
        com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
        sun.reflect.GeneratedConstructorAccessor35.newInstance(Unknown Source)
        sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
        com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
        com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
        com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146)
        com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195)
        com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184)
        com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
        com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
        com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
        com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810)
        com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648)
    Thread[C3P0PooledConnectionPoolManager[identityToken->1hge1389qdn08p6rqveaf|673cdf0c]-HelperThread-#1,5,main]
        java.net.SocketInputStream.socketRead0(Native Method)
        java.net.SocketInputStream.read(SocketInputStream.java:152)
        java.net.SocketInputStream.read(SocketInputStream.java:122)
        com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)
        com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)
        com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
        com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2452)
        com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:591)
        com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1070)
        com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2048)
        com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:723)
        com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
        sun.reflect.GeneratedConstructorAccessor35.newInstance(Unknown Source)
        sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
        com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
        com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
        com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146)
        com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195)
        com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184)
        com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
        com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
        com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
        com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
        com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810)
        com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648)

c3p0配置如下:

<bean id="caruseDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
        destroy-method="close">
        <property name="driverClass" value="${caruse.jdbc.driver}" />
        <property name="jdbcUrl" value="${caruse.jdbc.url}" />
        <property name="user" value="${caruse.jdbc.username}" />
        <property name="password" value="${caruse.jdbc.password}" />
        <property name="acquireIncrement" value="10"></property>
        <property name="idleConnectionTestPeriod" value="20"></property>
        <property name="maxPoolSize" value="30"></property>
        <property name="maxStatements" value="0"></property>
        <property name="maxStatementsPerConnection" value="50"></property>
        <property name="minPoolSize" value="10"></property>

<property name="testConnectionOnCheckin" value="true"></property>

<property name="preferredTestQuery" value="SELECT 1"></property>

        
    </bean>

 

跪求大神帮忙,十分感谢!

<无标签>
举报
Venus_sun
发帖于10个月前 1回/106阅
顶部