在我的应用程序中使用C3P0连接到DB服务器。这里DB服务器在防火墙后面运行。
防火墙有时行为不端,因为TCP连接变得半开,C3P0认为这些是有效的连接,并试图触发查询。 C3P0辅助线程正在进行这些半开放查询,应用程序线程正在挨饿。
`"com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1" daemon prio=10 tid=0x00007fec0865d000 nid=0xc1fe runnable [0x00007fec4cb66000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:152)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at com.ingres.gcf.dam.IoBuff.fillBuffer(Unknown Source)
at com.ingres.gcf.dam.IoBuff.next(Unknown Source)
- locked <0x0000000782455468> (a com.ingres.gcf.dam.InBuff)
at com.ingres.gcf.dam.InBuff.receive(Unknown Source)
at com.ingres.gcf.dam.MsgIn.receive(Unknown Source)
at com.ingres.gcf.dam.MsgConn.receive(Unknown Source)
at com.ingres.gcf.jdbc.DrvObj.readResults(Unknown Source)
at com.ingres.gcf.jdbc.JdbcConn.connect(Unknown Source)
at com.ingres.gcf.jdbc.JdbcConn.<init>(Unknown Source)
at com.ingres.gcf.jdbc.JdbcDrv.connect(Unknown Source)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:81)
- locked <0x0000000780025b10> (a com.mchange.v2.c3p0.DriverManagerDataSource)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:96)
- locked <0x0000000780025b70> (a com.mchange.v2.c3p0.WrapperConnectionPoolDataSource)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.acquireResource(C3P0PooledConnectionPool.java:89)
at com.mchange.v2.resourcepool.BasicResourcePool.acquireUntil(BasicResourcePool.java:665)
at com.mchange.v2.resourcepool.BasicResourcePool.access$500(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1206)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:368)
`
有没有可以解决这种情况的工作?
使用的数据库是VECTORWISE数据库。
答案 0 :(得分:0)
如果套接字读取,从应用程序的角度来看,无限期挂起 - 既没有成功也没有失败Exception
- c3p0唯一可以真正做到的就是把它们抽出来试图打断它们
您在上面显示的失败不在查询中,而是在Connection
获取中。您可以尝试设置maxAdministrativeTaskTime来计算时间。显然,如果c3p0无法获取Connections,则尝试使用DataSource
仍然会失败。但他们应该(最终,经过大量超时后,请acquireRetryAttempts和acquireRetryDelay)明确地与客户进行Exceptions
,而不是仅仅等待
(这取决于挂起对Thread.interrupt()
的敏感程度。如果它们无法中断,maxAdministrativeTaskTime
无法帮助。)