Mensagem de dead lock e too many connections

1 resposta
C

Pessoal, boa noite. Tenho uma aplicação que deve ficar rodando direto. A cada 10 segundos ela faz uma consulta no banco para verificar o último registro gravado. Só que ela está dando erro de dead lock e too many connections, conforma abaixo: Alguma dica?

21:35:27,453  INFO SettingsFactory:309 - Named query checking : enabled

21:35:27,453  INFO SessionFactoryImpl:161 - building session factory

21:35:27,453  WARN ConfigurationFactory:127 - No configuration found. Configuring ehcache from ehcache-failsafe.xml  found in the classpath: jar:file:/D:/workspace1/PortaJSFOK/WebContent/WEB-INF/lib/ehcache-1.2.3.jar!/ehcache-failsafe.xml

21:35:27,468  WARN CacheManager:271 - Creating a new instance of CacheManager using the diskStorePath C:\DOCUME~1\CARLOS~1\CONFIG~1\Temp which is already used by an existing CacheManager.

The source of the configuration was classpath.

The diskStore path for this CacheManager will be set to C:\DOCUME~1\CARLOS~1\CONFIG~1\Temp\ehcache_auto_created_1311122127468.

To avoid this warning consider using the CacheManager factory methods to create a singleton CacheManager or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance.

21:35:27,484  INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured

21:35:47,375  WARN ThreadPoolAsynchronousRunner:608 - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@1e8e144  APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!

21:35:47,390  WARN ThreadPoolAsynchronousRunner:624 - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@1e8e144  APPARENT DEADLOCK!!! Complete Status:

Managed Threads: 3

Active Threads: 3

Active Tasks:

com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@129df8a (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)

com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@12e4cd (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1)

com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@6b51d8 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2)

Pending Tasks:

com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1ca5df9

com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask@df9095

Pool thread stack traces:

Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main]

java.lang.Thread.sleep(Native Method)

com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805)

com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)

Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main]

java.lang.Thread.sleep(Native Method)

com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805)

com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)

Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main]

java.lang.Thread.sleep(Native Method)

com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805)

com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Hibernate:

select

evento0_.id as col_0_0_

from

Evento evento0_

where

evento0_.id=(

select

max(evento1_.id)

from

Evento evento1_

)

Hibernate:

select

evento0_.id as id40_0_,

evento0_.dataGravacao as dataGrav2_40_0_,

evento0_.evento0 as evento3_40_0_,

evento0_.evento1 as evento4_40_0_,

evento0_.evento2 as evento5_40_0_,

evento0_.evento3 as evento6_40_0_,

evento0_.evento4 as evento7_40_0_

from

Evento evento0_

where

evento0_.id=?

[red]

[red]

[red]

[red]

[green]

[red]

[red]

[red]

[red]

[green]

evento 2:red

Populado!

abyte248

abyte120

Input from parallel port: 1111000

red

red

red

red

green

21:35:47,406  INFO Configuration:1426 - configuring from resource: /hibernate.cfg.xml

21:35:47,406  INFO Configuration:1403 - Configuration resource: /hibernate.cfg.xml

21:35:47,421  INFO Configuration:1541 - Configured SessionFactory: null

21:35:47,421  INFO AnnotationBinder:398 - Binding entity from annotated class: modelo.Evento

21:35:47,421  INFO EntityBinder:420 - Bind entity modelo.Evento on table Evento

21:35:47,437  INFO AnnotationConfiguration:350 - Hibernate Validator not found: ignoring

21:35:47,437  INFO C3P0ConnectionProvider:81 - C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/projeto

21:35:47,437  INFO C3P0ConnectionProvider:82 - Connection properties: {user=root, password=****}

21:35:47,437  INFO C3P0ConnectionProvider:85 - autocommit mode: false

21:35:56,531  WARN BasicResourcePool:1841 - com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@129df8a  Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:

com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Data source rejected establishment of connection,  message from server: "Too many connections"

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:921)

Grato, Carlos.

1 Resposta

rmendes08

Provavelmente você está criando uma sessão de 10s em 10s. Crie apenas uma, fora do laço e reaproveite-a. Além do mais, se é uma consulta SQL comum, para ler uma linha da tabela, eu utilizaria JBDC puro mesmo.

Criado 19 de julho de 2011
Ultima resposta 19 de jul. de 2011
Respostas 1
Participantes 2