论坛首页 Java企业应用论坛

c3p0存在严重bug

浏览 34429 次
精华帖 (1) :: 良好帖 (6) :: 新手帖 (0) :: 隐藏帖 (1)
作者 正文
   发表时间:2011-11-03  
bao231 写道
40并发这样基本的性能测试都不过,这样的程序可能嘛?
感觉楼主分析的问题不透彻啊,你这样的分析都是猜测,你这样分析问题只能越分析越乱啊,把你的c3p0的jar包发一下,然后把你的程序配置文件发一下,还有程序代码发一下,这样才能找到错误的原因。

我补充了帖子内容,并上传了一个c3p0的测试程序
发生 DEADLOCK 的问题,是需要一些前提条件的
0 请登录后投票
   发表时间:2011-11-03  
yacki 写道
楼主的数据和应用服务器之间是不是存在防火墙?

我遇到过防火墙配置不正确导致报同样的错误。

嗯,防火墙有可能影响数据库连接创建的时间
0 请登录后投票
   发表时间:2011-11-03  
wubg 写道
Some highlights:

我也困扰很久,明天用这个参数也试一下,希望能够解决,
出现这个问题,一般只针对oracle数据库

我补充了帖子内容,增加了测试程序,DEADLOCK问题应该是c3p0实现上的bug
0 请登录后投票
   发表时间:2011-11-03  
flyingfish235 写道
哪里配置有问题吧,我们经过压力测试,1K以上的并发量都没有问题

APPARENT DEADLOCK问题的发生是需要一些前提条件的,我在帖子中补充了
0 请登录后投票
   发表时间:2011-11-03  
yunzhu 写道
这种问题估计让LZ纠结了很久啊,不过每次解决一个这样的难题,那叫一个成就感十足啊,哈哈

你说对了,^_^
0 请登录后投票
   发表时间:2011-11-03  
之前也遇到一个问题,用C3P0连接oracle,直接杀jvm,连接断不掉,结果配了60个连接,调试程序的时候,没一会就获得不到连接了,结果一查,oracle的session满了。
后来使用tomcat的stop,连接断掉了。
原来用jdbc是ok的,换成c3p0就不行了,应该是存在bug的
0 请登录后投票
   发表时间:2011-11-03   最后修改:2011-11-03
wubg 写道
Some highlights:

+ Some JDBC drivers freeze up if cached Statements are close()ed while their parent
  Connections are in use. Previously users of these drivers (Oracle, JTDS) generally
  had to forego Statement caching to avoid deadlocks. C3P0's statement cache can now
  be set to cautiously close Statements only when the parent Connections are known
  to be idle. If you experience "APPARENT DEADLOCKS" due to StatementCloseTasks, set

      c3p0.statementCacheNumDeferredCloseThreads=1

下最新版本:c3p0-0.9.2-pre1.jar

官方文档是这样描述的,设置这个线程 用于回收没用的连接池,


statementCacheNumDeferredCloseThreads
Default: 0
If set to a value greater than 0, the statement cache will track when Connections are in use, and only destroy Statements when their parent Connections are not otherwise in use. Although closing of a Statement while the parent Connection is in use is formally within spec, some databases and/or JDBC drivers, most notably Oracle, do not handle the case well and freeze, leading to deadlocks. Setting this parameter to a positive value should eliminate the issue. This parameter should only be set if you observe that attempts by c3p0 to close() cached statements freeze (usually you'll see APPARENT DEADLOCKS in your logs). If set, this parameter should almost always be set to 1. Usually, if you need more than one Thread dedicated solely to destroying cached Statements, you should set maxStatements and/or maxStatementsPerConnection so that you don't churn through Statements so quickly

我也困扰很久,明天用这个参数也试一下,希望能够解决,
出现这个问题,一般只针对oracle数据库



今天 试了一下,配置了这个参数,OK,并发50,没问题
0 请登录后投票
   发表时间:2011-11-07  
com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@114bb71 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@114bb71 -- APPARENT DEADLOCK!!! Complete Status:
Managed Threads: 3
Active Threads: 3
Active Tasks:
com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask@f5d9f (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2)
com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask@cbb261 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)
com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask@12c101f (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1)
Pending Tasks:
com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask@1d69a31
com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask@251437
com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask@525416
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1af9dfe
Pool thread stack traces:
Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main]
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.read(SocketInputStream.java:129)
oracle.net.ns.Packet.receive(Unknown Source)
oracle.net.ns.DataPacket.receive(Unknown Source)
oracle.net.ns.NetInputStream.getNextPacket(Unknown Source)
oracle.net.ns.NetInputStream.read(Unknown Source)
oracle.net.ns.NetInputStream.read(Unknown Source)
oracle.net.ns.NetInputStream.read(Unknown Source)
oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1103)
oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1074)
oracle.jdbc.driver.T4C7Ocommoncall.receive(T4C7Ocommoncall.java:105)
oracle.jdbc.driver.T4CConnection.logoff(T4CConnection.java:464)
oracle.jdbc.driver.PhysicalConnection.close(PhysicalConnection.java:1202)
com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:549)
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


这又是什么情况?
0 请登录后投票
   发表时间:2011-11-07  
xiaokedou123 写道
com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@114bb71 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@114bb71 -- APPARENT DEADLOCK!!! Complete Status:
Managed Threads: 3
Active Threads: 3
Active Tasks:
com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask@f5d9f (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2)
com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask@cbb261 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)
com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask@12c101f (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1)
Pending Tasks:
com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask@1d69a31
com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask@251437
com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask@525416
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1af9dfe
Pool thread stack traces:
Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main]
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.read(SocketInputStream.java:129)
oracle.net.ns.Packet.receive(Unknown Source)
oracle.net.ns.DataPacket.receive(Unknown Source)
oracle.net.ns.NetInputStream.getNextPacket(Unknown Source)
oracle.net.ns.NetInputStream.read(Unknown Source)
oracle.net.ns.NetInputStream.read(Unknown Source)
oracle.net.ns.NetInputStream.read(Unknown Source)
oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1103)
oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1074)
oracle.jdbc.driver.T4C7Ocommoncall.receive(T4C7Ocommoncall.java:105)
oracle.jdbc.driver.T4CConnection.logoff(T4CConnection.java:464)
oracle.jdbc.driver.PhysicalConnection.close(PhysicalConnection.java:1202)
com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:549)
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


这又是什么情况?


DestroyResourceTask -- 销毁一个资源(数据库连接)也是需要使用内部线程池的
也可能产生APPARENT DEADLOCK问题
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics