在Tomcat上部署的DBCP中的死锁问题 [英] Deadlock issue in DBCP deployed on Tomcat

查看:242
本文介绍了在Tomcat上部署的DBCP中的死锁问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Spring配置中使用DBCP数据源(默认配置)来管理我与数据库的连接,当客户端数量增加时,我遇到了死锁状态。

I'm using DBCP data source (with default configuration) in Spring configuration to manage my connections to the database, and I'm running into a deadlock condition when the number of clients increase.

我发现在我使用的DBCP 1.2.1中存在死锁问题,应该在1.4中解决。所以我升级到1.4,但问题仍然存在。

I found that there is a deadlock issue in DBCP 1.2.1 which I was using, which was supposed to be resolved in 1.4. So I upgraded to 1.4, but the issue still persists.

在线程转储中,有许多线程被阻塞,顶部有以下堆栈跟踪:

In the thread dump, there are many threads blocked with the following stack trace on top:

   java.lang.Thread.State: WAITING on org.apache.commons.pool.impl.GenericObjectPool$Latch@b6b09e
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:485)
at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1104)
at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:106)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:200)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:350)
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:261)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:160)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:631)

欢迎任何建议!

推荐答案

我切换到 c3p0 。你可以试试。我相信你不需要改变太多,这只是一个配置游戏。

I switched to c3p0, few years back. You can try that. I believe you didn't have to change much, it's just a game of configuration.

有点相关的线程,使用JDBC的连接池选项:DBCP与C3P0 。好吧,实际上我把它与之相关。

Somewhat related thread, Connection pooling options with JDBC: DBCP vs C3P0. Well, actually I made it related.

Tomcat 7有一个不错的连接池, Tomcat JDBC Connection游泳池

Tomcat 7 has a decent connection pool, The Tomcat JDBC Connection Pool.

这篇关于在Tomcat上部署的DBCP中的死锁问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆