Re: [c3p0-users] c3p0 connection leak problem
Status: Beta
Brought to you by:
swaldman
|
From: Steve W. <swa...@mc...> - 2013-02-22 11:27:34
|
no, of course there shouldn't be thousands of Connections.
and c3p0's not seeing thousands of Connections: it's trying to acquire new ones, which means it is managing less than maxPoolSize. the usual signature of a Connection leak is that the app hangs: maxPoolSize Connections are managed, but none are in the pool. what you are seeing is something else. if there are lots of Connections from your JVM to the database, it's clear that 1) c3p0 has purged these Connections and thinks they are closed, but they are not; or 2) you have accidentally created many different Connection pools rather than the ordinary one pool per app.
first, you should verify that there actually are all these open Connections, and that they originate from your JVM. (again, lsof or an equivalent.)
then, what's going on in your app's log files? are multiple c3p0 pools getting initialized? are Exceptions occurring (and getting logged) during Connection.close()?
do you monitor your pools via JMX? do you see many live pools? anything odd in the pool stats?
smiles,
steve
On Feb 22, 2013, at 3:05 AM, yavuz gokirmak wrote:
> Hi Steve,
>
> It is reported that on the database side, we have lots of connections. But the strange point is we set maxpoolsize as well, there shouldn't be thousands of connections..
> Am I right?
>
>
> On 22 February 2013 12:53, Steve Waldman <swa...@mc...> wrote:
> hi,
>
> so a Connection "leak" usually means Connections get opened but never closed. here, the immediate error, Connections are failing to open. do you have reason to think that the 1023 open file descriptors represent Connections that were opened but never closed? you might try analyzing the output of lsof (or your operating system's equivalent) to see what these files are. it's possible something else on the machine is bringing open files to their limit, and c3p0 is only experiencing a failure caused by that. (if this is happening, you might not even be able to do a DNS lookup, so the UnknownHostException is not surprising.) alternatively, if you do have hundreds of database Connections somehow opened and never closed, that would be worth looking into.
>
> good luck!
>
> steve
>
>
>
>
> On Feb 22, 2013, at 2:42 AM, yavuz gokirmak wrote:
>
> > Hi,
> >
> >
> > I have an application that have several threads and using c3p0 for lots of database queries.
> > Application works well in several environments but I have problem in one of installations.
> >
> > The reason why I give this information is that we know that there is no connection leak in the code,
> > but somehow we face with connection problems in one installation.
> >
> > Below is the error I get. This error is caught repeatedly after some case and as I saw we have lots of open files ( 1023 open file descriptors while the limit is 1024 ) in the system. Open file problem may trigger the below error or the reverse is the case.
> >
> > It is strange that I get "Caused by: java.net.UnknownHostException: name_of_host" unknowhost exceptions.
> > This may be the reason for connection problem but the question is,
> > Is this a reason for connection leak? What is your idea?
> >
> >
> > ------------------
> >
> > 21/Feb/2013 15:11:57 WARN 137479890 [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] com.mchange.v2.resourcepool.BasicResourcePool(L:1841) - com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@2387802 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (5). Last acquisition attempt exception:
> > java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
> > at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:458)
> > at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546)
> > at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:236)
> > at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
> > at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
> > at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
> > at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
> > at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:148)
> > at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
> > at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
> > at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
> > at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
> > Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection
> > at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:392)
> > at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:434)
> > at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:687)
> > at oracle.net.ns.NSProtocol.connect(NSProtocol.java:247)
> > at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1102)
> > at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:320)
> > ... 11 more
> > Caused by: java.net.UnknownHostException: name_of_host
> > at java.net.InetAddress.getAllByName0(InetAddress.java:1201)
> > at java.net.InetAddress.getAllByName(InetAddress.java:1128)
> > at java.net.InetAddress.getAllByName(InetAddress.java:1064)
> > at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:117)
> > at oracle.net.nt.ConnOption.connect(ConnOption.java:133)
> > at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:370)
> > ... 16 more
> >
> > -------------------
>
>
|