2012-07-26 2 views
2

webservice - java/hibernate/mysql/innoDB가 있습니다. 계속해서 교착 상태 예외가 발생합니다. hibernate.cfg :java + hibernate webservice - append deadlock

<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property> 
    <property name="connection.autoReconnect">true</property> 
    <property name="connection.autoReconnectForPools">true</property> 
    <property name="connection.is-connection-validation-required">true</property> 
    <property name="hibernate.connection.zeroDateTimeBehavior">convertToNull</property> 
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> 
    <property name="hibernate.show_sql">false</property> 
    <property name="hibernate.current_session_context_class">thread</property> 
    <property name="hibernate.format_sql">true</property> 
    <property name="hibernate.use_sql_comments">true</property> 
    <property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property> 

    <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property> 
    <property name="hibernate.c3p0.min_size">5</property> 
    <property name="hibernate.c3p0.max_size">50</property> 
    <property name="hibernate.c3p0.timeout">1800</property> 
    <property name="hibernate.c3p0.max_statements">50</property> 
    <property name="hibernate.c3p0.acquire_increment">1</property> 
    <!-- this property forces the revalidation of a connection after the given amount of time (in secs) --> 
    <!-- it must be set to LESS than the wait_timout setting for the mysql server (this setting defaults to 28800 secs (8 hours)) --> 
    <property name="hibernate.c3p0.idle_test_period">2100</property> 

c3p0.properties 은 내가 내 최대 절전 모드 CFG에 다음을 사용하고

... 그물 둘러보고 및 제안하지만 여전히 문제가 있었는지 시도했다 :

c3p0.properties

c3p0.testConnectionOnCheckout = 사실

c3p0.preferredTest 쿼리 = 선택 1;

[WARN] com[email protected]1e5161e1 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks! 
[WARN] com[email protected]1e5161e1 -- APPARENT DEADLOCK!!! Complete Status: 
    Managed Threads: 3 
    Active Threads: 3 
    Active Tasks: 
     com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdle[email protected] (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0) 
     com.mcha[email protected]4f7eae6c (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1) 
     com.mcha[email protected]5ed5d3a (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2) 
    Pending Tasks: 
     com.mcha[email protected]22838de0 
     com.mcha[email protected]6ad77ed3 
Pool thread stack traces: 
    Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main] 
     java.net.SocketInputStream.socketRead0(Native Method) 
     java.net.SocketInputStream.read(SocketInputStream.java:146) 
     com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:114) 
     com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:161) 
     com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:189) 
     com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2537) 
     com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2990) 
     com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2979) 
     com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3520) 
     com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990) 
     com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151) 
     com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2619) 
     com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2569) 
     com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1521) 
     com.mchange.v2.c3p0.impl.NewProxyStatement.executeQuery(NewProxyStatement.java:35) 
     com.mchange.v2.c3p0.impl.DefaultConnectionTester.activeCheckConnection(DefaultConnectionTester.java:73) 
     com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.testPooledConnection(C3P0PooledConnectionPool.java:374) 
     com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.refurbishIdleResource(C3P0PooledConnectionPool.java:310) 
     com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask.run(BasicResourcePool.java:1999) 
     com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) 
    Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main] 
     java.net.SocketInputStream.socketRead0(Native Method) 
     java.net.SocketInputStream.read(SocketInputStream.java:146) 
     com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:114) 
     com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:161) 
     com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:189) 
     com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2537) 
     com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2990) 
     com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2979) 
     com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3520) 
     com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990) 
     com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151) 
     com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2619) 
     com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2569) 
     com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1521) 
     com.mchange.v2.c3p0.impl.NewProxyStatement.executeQuery(NewProxyStatement.java:35) 
     com.mchange.v2.c3p0.impl.DefaultConnectionTester.activeCheckConnection(DefaultConnectionTester.java:73) 
     com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.testPooledConnection(C3P0PooledConnectionPool.java:374) 
     com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.refurbishIdleResource(C3P0PooledConnectionPool.java:310) 
     com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask.run(BasicResourcePool.java:1999) 
     com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) 
    Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main] 
     java.net.SocketInputStream.socketRead0(Native Method) 
     java.net.SocketInputStream.read(SocketInputStream.java:146) 
     com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:114) 
     com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:161) 
     com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:189) 
     com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2537) 
     com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2990) 
     com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2979) 
     com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3520) 
     com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990) 
     com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151) 
     com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2619) 
     com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2569) 
     com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1521) 
     com.mchange.v2.c3p0.impl.NewProxyStatement.executeQuery(NewProxyStatement.java:35) 
     com.mchange.v2.c3p0.impl.DefaultConnectionTester.activeCheckConnection(DefaultConnectionTester.java:73) 
     com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.testPooledConnection(C3P0PooledConnectionPool.java:374) 
     com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.refurbishIdleResource(C3P0PooledConnectionPool.java:310) 
     com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask.run(BasicResourcePool.java:1999) 
     com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) 


[WARN] Task com.mcha[email protected]60dd0912 (in deadlocked PoolThread) failed to complete in maximum time 60000ms. Trying interrupt(). 
[WARN] Task com.mcha[email protected]4f7eae6c (in deadlocked PoolThread) failed to complete in maximum time 60000ms. Trying interrupt(). 
[WARN] Task com.mcha[email protected]5ed5d3a (in deadlocked PoolThread) failed to complete in maximum time 60000ms. Trying interrupt(). 
[WARN] com[email protected]1e5161e1 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks! 
[WARN] com[email protected]1e5161e1 -- APPARENT DEADLOCK!!! Complete Status: 
    Managed Threads: 3 
    Active Threads: 3 
    Active Tasks: 
     com[email protected]555214b9 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0) 
     com[email protected]7fcea971 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2) 
     com[email protected]58d67b44 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1) 
    Pending Tasks: 
     com[email protected]6936daec 
     [email protected]eb 
     [email protected]b2 
     [email protected]be 
     [email protected]7c 
Pool thread stack traces: 
    Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main] 
     com.mysql.jdbc.StatementImpl.close(StatementImpl.java:550) 
     com.mchange.v2.c3p0.impl.NewPooledConnection.cleanupUncachedStatements(NewPooledConnection.java:651) 
     com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:539) 
     com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:234) 
     com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:470) 
     com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:964) 
     com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) 
    Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main] 
     com.mysql.jdbc.StatementImpl.close(StatementImpl.java:550) 
     com.mchange.v2.c3p0.impl.NewPooledConnection.cleanupUncachedStatements(NewPooledConnection.java:651) 
     com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:539) 
     com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:234) 
     com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:470) 
     com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:964) 
     com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) 
    Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main] 
     com.mysql.jdbc.StatementImpl.close(StatementImpl.java:550) 
     com.mchange.v2.c3p0.impl.NewPooledConnection.cleanupUncachedStatements(NewPooledConnection.java:651) 
     com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:539) 
     com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:234) 
     com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:470) 
     com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:964) 
     com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) 


[WARN] Task com[email protected]555214b9 (in deadlocked PoolThread) failed to complete in maximum time 60000ms. Trying interrupt(). 
[WARN] Task com[email protected]7fcea971 (in deadlocked PoolThread) failed to complete in maximum time 60000ms. Trying interrupt(). 
[WARN] Task com[email protected]58d67b44 (in deadlocked PoolThread) failed to complete in maximum time 60000ms. Trying interrupt(). 
+1

교착 상태는 연결 풀 관련 문제보다 SQL 프로그래밍 문제입니다. 교착 상태는 프로세스 1이 테이블 A를 잠그고 테이블 B를 잠그기를 기다리고 프로세스 2가 테이블 B를 잠그고 A를 기다리고있을 때입니다. –

답변

1

당신이 뭘 하려는지 :

나는 다음과 같은 예외가? 데이터베이스 연결을 유지하고있는 뭔가가있는 것 같습니다. 결과적으로 c3p0은 추가 요청을 처리하기 위해 더 많은 연결을 얻으려고합니다.

+0

코드에서 사방에 session.commit()이 필요하기 때문에 이상하게 들립니다. . 그래서 연결은 닫혀 야합니다. 나 맞아? – user1365799

+0

session.commit()이 데이터베이스 연결을 닫지 않습니다. 절대 커밋하거나 롤백하지 않는 트랜잭션을 사용하고 있습니까? –

+0

내 모든 트랜잭션이 커밋/롤백 중입니다. 각 ServerAPI 함수는 트랜잭션을 가져오고 항상 커밋/롤백을합니다. 문제 해결에 도움이되는 정보를 더 제공해야한다면 - 제공 해줄 것입니다. – user1365799