文章转自 http://japi.iteye.com/blog/243702
- [framework] 2008-09-18 18:36:05,109 - com.mchange.v2.async.ThreadPoolAsynchronousRunner -46651078 [Timer-18] WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@1c17bd4 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
网上说是连接池的原因....
我的C3P0配置
- <property name="hibernate.connection.provider_class">
- org.hibernate.connection.C3P0ConnectionProvider
- </property>
- <property name="c3p0.min_size">20</property>
- <property name="c3p0.max_size">200</property>
- <property name="c3p0.time_out">1800</property>
- <property name="c3p0.max_statement">100</property>
- <property name="c3p0.validate">true</property>
对于以上错误,查阅了类似问题网友的解答:
一:http://www.iteye.com/topic/22160?page=3
引用
把max_statements设置为0。
c3p0在同时关闭statement和connection的时候,或者关闭他们之间的时间很短的时候,有时候connection并没有被关闭,因为有些preparedstatement还在被cached住。这是c3p0的作者自己说的。
http://forum.hibernate.org/viewtopic.php?t=947246&highlight=apparent+deadlock+c3p0
c3p0在同时关闭statement和connection的时候,或者关闭他们之间的时间很短的时候,有时候connection并没有被关闭,因为有些preparedstatement还在被cached住。这是c3p0的作者自己说的。
http://forum.hibernate.org/viewtopic.php?t=947246&highlight=apparent+deadlock+c3p0
对于这个解答,看下我的设置:
- <property name="c3p0.max_statement">100</property>
因为这里c3p0.max_statements写错了,所以设置无效,看下日志
- [framework] 2008-09-18 06:32:48,906 - com.mchange.v2.c3p0.C3P0Registry -3257219 [TP-Processor1] INFO com.mchange.v2.c3p0.C3P0Registry - Initializing c3p0-0.9.1 [built 16-January-2007 14:46:42; debug? true; trace: 10]
- [framework] 2008-09-18 06:32:48,906 - com.mchange.v2.c3p0.management.ActiveManagementCoordinator -3257219 [TP-Processor1] WARN com.mchange.v2.c3p0.management.ActiveManagementCoordinator - A C3P0Registry mbean is already registered. This probably means that an application using c3p0 was undeployed, but not all PooledDataSources were closed prior to undeployment. This may lead to resource leaks over time. Please take care to close all PooledDataSources.
- [framework] 2008-09-18 06:32:49,015 - com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource -3257328 [TP-Processor1] INFO com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource - Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@7111383 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@a9b46d3 [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 2rysjs7wvr5h721dikp1v|1880048, idleConnectionTestPeriod -> 0, initialPoolSize -> 20, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 200, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 20, nestedDataSource ->
maxStatements的默认值为0
所以这种解决方法,感觉不行
二.http://yonguo.iteye.com/blog/120574
引用
更改配置文件里的最大连接数和初始化连接数大小:
因为数据库的连接数是有限的,每次应用启动C3p0都会占用数据库的连接来填充C3p0的连接池,而当数据库的资源被占光时就会因为无法获得共享资源而报死锁。
- <property name="maxPoolSize" value="1"/>
- <property name="initialPoolSize" value="1"/>
因为数据库的连接数是有限的,每次应用启动C3p0都会占用数据库的连接来填充C3p0的连接池,而当数据库的资源被占光时就会因为无法获得共享资源而报死锁。
此方法可能有理,但没有测试.
三.http://www.iteye.com/problems/1082
引用
Basic Pool Configuration
c3p0 Connection pools are very easy to configure via the following basic parameters:
acquireIncrement
initialPoolSize
maxPoolSize
maxIdleTime
minPoolSize
initialPoolSize, minPoolSize, maxPoolSize define the number of Connections that will be pooled. Please ensure that minPoolSize <= maxPoolSize. Unreasonable values of initialPoolSize will be ignored, and minPoolSize will be used instead.
Within the range between minPoolSize and maxPoolSize, the number of Connections in a pool varies according to usage patterns. The number of Connections increases whenever a Connection is requested by a user, no Connections are available, and the pool has not yet reached maxPoolSize in the number of Connections managed. Since Connection acquisition is very slow, it is almost always useful to increase the number of Connections eagerly, in batches, rather than forcing each client to wait for a new Connection to provoke a single acquisition when the load is increasing. acquireIncrement determines how many Connections a c3p0 pool will attempt to acquire when the pool has run out of Connections. (Regardless of acquireIncrement, the pool will never allow maxPoolSize to be exceeded.)
The number of Connections in a pool decreases whenever a pool tests a Connection and finds it to be broken (see Configuring Connection Testing below), or when a Connection is expired by the pool after sitting idle for a period of time, or for being too old (See Managing Pool Size and Connection Age.)
c3p0 Connection pools are very easy to configure via the following basic parameters:
acquireIncrement
initialPoolSize
maxPoolSize
maxIdleTime
minPoolSize
initialPoolSize, minPoolSize, maxPoolSize define the number of Connections that will be pooled. Please ensure that minPoolSize <= maxPoolSize. Unreasonable values of initialPoolSize will be ignored, and minPoolSize will be used instead.
Within the range between minPoolSize and maxPoolSize, the number of Connections in a pool varies according to usage patterns. The number of Connections increases whenever a Connection is requested by a user, no Connections are available, and the pool has not yet reached maxPoolSize in the number of Connections managed. Since Connection acquisition is very slow, it is almost always useful to increase the number of Connections eagerly, in batches, rather than forcing each client to wait for a new Connection to provoke a single acquisition when the load is increasing. acquireIncrement determines how many Connections a c3p0 pool will attempt to acquire when the pool has run out of Connections. (Regardless of acquireIncrement, the pool will never allow maxPoolSize to be exceeded.)
The number of Connections in a pool decreases whenever a pool tests a Connection and finds it to be broken (see Configuring Connection Testing below), or when a Connection is expired by the pool after sitting idle for a period of time, or for being too old (See Managing Pool Size and Connection Age.)
四.http://blog.sina.com.cn/s/blog_3e7ed9500100abzz.html
根据以上的一些解答,修改配置文件:
- <property name="hibernate.connection.provider_class">
- org.hibernate.connection.C3P0ConnectionProvider
- </property>
- <!-- 初始化默认为20 -->
- <property name="initialPoolSize">1</property>
- <property name="c3p0.min_size">1</property>
- <property name="c3p0.max_size">500</property>
- <property name="c3p0.time_out">1800</property>
- <!--每隔100秒检测连接是否可正常使用 -->
- <property name="c3p0.idle_test_period">1000</property>
- <property name="c3p0.validate">true</property>
- <property name="hibernate.c3p0.acquire_increment">3</property>
对于这种配置也不知道结果会怎么样?
不知道有没有什么测试方法能马上看到效果?
其实hibernate里支持的c3p0参数没有多少.更多的还得在c3p0.property文件中定义
http://www.mchange.com/projects/c3p0/index.html#c3p0_properties
相关推荐
网上传言C3P0是因为本身的BUG问题,然而今天我遇到这个问题并解决了,结果发现并不是。通过配置c3p0.maxStatements=0 这种方案只是治标不治本,或者干脆无效。我上传的解决方案肯定能解决这个问题的根本原因。出现...
SQL Server上的一个奇怪的Deadlock及其分析方法 Deadlock是SQL Server中的一种常见问题,它会导致事务无法继续执行,影响...通过这个示例,我们可以了解Deadlock的产生原因和解决方法,提高SQL Server的性能和可靠性。
当遇到无法访问MySQL数据库时,可能会出现如描述中的异常情况:“ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@75d634ea -- APPARENT DEADLOCK!...
"power_flow.zip_apparent_流动_流动方程_能量方程_能量流动"这个标题暗示了我们正在探讨的是电力系统的功率流分析,这涉及到电能如何在电网中传输。"apparent flow"(视在流动)和"流动方程"可能指的是电路理论中的...
通过Apparent,开发者可以编写出更清晰、更易读的代码,同时也减少了因为类型转换和错误处理导致的潜在问题。这对于大型项目和团队协作尤其重要,因为它提高了代码的一致性和可维护性。 总结来说,Apparent是一个...
"Apparent Contour" 是一个开源项目,专注于处理三维(3D)模型的外观轮廓。在计算机图形学中,外观轮廓是指当一个3D对象被渲染时,由于法线(normal)与观察者视线(view direction)垂直而形成的边缘。这些轮廓在...
程序语言为Fortran,计算速度快,程序可改性也很强,欢迎学习电法的同行来下载!
神经网络中单离子通道问题的一篇很老的文章
表观太阳时间该应用程序可计算特定位置和时间范围内的太阳能数据。 它利用了和 。 为了运行此演示应用程序的实例,您需要生成自己的API密钥,并从~/config.js文件中导出它们: const geocodeApiKey = 'YOUR_OWN_...
Direction information of the palmprint provides one of the most promising features for palmprint recognition.... The method first extracts the apparent direction from the surface layer o
使用的是函数requests.get(),已写header、cookie、User-Agent,也写了rsp.encoding = rsp.apparent_encoding。 但是仍是爬取不了。奇怪的同一个网站同一个榜单,只是页数不同,前若干页能爬取,后若干页就爬取不了...
1. 第一级:外在的常规解决方案(Apparent or Conventional Solution) 这是最基础的改进,通常是现有解决方案的微小改变,不会显著改变产品的核心功能或技术。 2. 第二级:基于产品的创新(Small Invention ...
r.encoding = r.apparent_encoding html = etree.HTML(r.text) links = html.xpath("//div[@class='pic']/ul/li/a/@href") for link in links: link = link get_img_urls(link) break ``` - 这段代码定义了...
2048:APParent Intersection(在观察方向上相交的点) 4096:EXTension(延长线上的点) 8192:PARallel(与所选对象平行的点) 通过 setvar 函数可以设置目标捕捉的类型,例如: (setvar "osmode" 1);设置目标...
- 本题中的根是指多项式在模 `p` 意义下的根,即 `0 <= root < p`。 - 题目中提到的每个多项式都有固定的根的数量。 2. **输入格式**: - 输入未完全给出,但根据题目的描述,应该会包含多项式的系数以及模数 `p...
此外,Rsh也有两种表示方式:Rsh (Gref)和Rsh (0),其中Rsh (Gref)是默认的并联电阻值,Rsh (0)是与温度相关的系数。Rsh (exp)是一个指数,用于描述Rsh随温度变化的关系。通过调整这些参数,可以更精确地模拟组件在...
1. 错误的理解与表达:在题目中的第1题,"slip"一词在语境中指的是演讲中的一个小错误或疏忽,而不是选择、借口或声明。这种理解对于语言学习者来说很重要,因为正确识别词汇在不同情境下的含义是提升语言能力的关键...
The negative aspects are also apparent. One of the important disadvantages is that ----------------(A 的第一个缺点).To make matters worse,------------------(A 的第二个缺点). Through the above ...