C3P0 半开连接关闭
C3P0 half open connections closing
在我的应用程序中,我使用 C3P0 连接到数据库服务器。这里的数据库服务器在防火墙后面 运行。
防火墙有时会因 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.acquireResource(C3P0PooledConnectionPool.java:89)
at com.mchange.v2.resourcepool.BasicResourcePool.acquireUntil(BasicResourcePool.java:665)
at com.mchange.v2.resourcepool.BasicResourcePool.access0(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数据库
如果套接字读取,从应用程序的角度来看,无限期挂起——既不成功也不失败 Exception
——c3p0 唯一真正能做的就是暂停它们并尝试打断他们。
您上面显示的失败不是在查询中,而是在 Connection
获取中。您可以尝试设置 maxAdministrativeTaskTime to time this out. Obviously, if c3p0 can't fetch Connections, attempts to use your DataSource
will still fail. But they should (eventually, after a lot of timeouts, see acquireRetryAttempts and acquireRetryDelay) 显式中断,使用 Exceptions
给客户端,而不是永远等待
(这取决于挂起对 Thread.interrupt()
的敏感性。如果不能被打断 maxAdministrativeTaskTime
也无济于事。)
在我的应用程序中,我使用 C3P0 连接到数据库服务器。这里的数据库服务器在防火墙后面 运行。
防火墙有时会因 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.acquireResource(C3P0PooledConnectionPool.java:89)
at com.mchange.v2.resourcepool.BasicResourcePool.acquireUntil(BasicResourcePool.java:665)
at com.mchange.v2.resourcepool.BasicResourcePool.access0(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数据库
如果套接字读取,从应用程序的角度来看,无限期挂起——既不成功也不失败 Exception
——c3p0 唯一真正能做的就是暂停它们并尝试打断他们。
您上面显示的失败不是在查询中,而是在 Connection
获取中。您可以尝试设置 maxAdministrativeTaskTime to time this out. Obviously, if c3p0 can't fetch Connections, attempts to use your DataSource
will still fail. But they should (eventually, after a lot of timeouts, see acquireRetryAttempts and acquireRetryDelay) 显式中断,使用 Exceptions
给客户端,而不是永远等待
(这取决于挂起对 Thread.interrupt()
的敏感性。如果不能被打断 maxAdministrativeTaskTime
也无济于事。)