-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: hibernate 2.1.8 - c3p0 0.8.5.2 - orphaned connections
PostPosted: Mon Jan 15, 2007 4:48 pm 
Newbie

Joined: Mon Jan 15, 2007 3:57 pm
Posts: 2
Location: Germany
Hello.
We run a high end Internetwebshop using springframework.
Hibernate Sessions and through them the connection pool are handled by spring and we never experienced any connection leaking.
A few weeks ago we started to register orphaned connections in the connection pool of the production environment. I found no doc on what would cause them.
Newer versions of c3p0 mention that they only occur when the new reset-methods are used (forcing the pool to replace the connections in the pool and abondon the old connections)

The tomcat-log shows jdbc-connection-resets.

So I wonder:
a) What causes orphaned connections and what happens to threads using those connections, when they are orphaned?
b) Are the jdbc-connection-resets the cause that leads to an orphaned connection or the result?

Thanks a lot.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 16, 2007 3:08 pm 
C3P0 Developer
C3P0 Developer

Joined: Tue Jan 06, 2004 8:58 pm
Posts: 145
hi,

how are you observing the "orphaned Connections"? what is it that you are actually seeing?

c3p0 maintains statistics about "unclosed orphaned Connections", which as you note occur when a c3p0 pool is "soft reset" — the pool is refreshed with new Connections from the database, but any checked-out Connections are not destroyed, but considered "orphaned". They will be close()ed when clients try to check them back into the pool.

it's quite possible to have Connections be orphaned even if you never explicitly call a softReset() method. Should a c3p0 DataSource observe an error that signals (according its ConnectionTester) that currently pooled Connections are likely to be invalid, the pool will softReset() internally. so, if you've observed database problems/Connection errors etc, its quite possible that c3p0 saw an Exception, deemed it likely that all pooled Connections have broken, and reset the pool.

if this is causing you problems somehow, you can write your own ConnectionTester that never returns ConnectionTester.DATABASE_IN_INVALID. (You can delegate to c3p0's default ConnectionTester for most of the implementation.)

good luck!
Steve

p.s. c3p0-0.8.5.x is very old; you might try upgrading to newer versions. any newer c3p0 is a drop-in replacement for previous versions, just copy a newer c3p0 jar file into hibernate's lib directory and remove the old one. if you have any problems with the newer version, downgrading is just a matter of switching jar files once again.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 17, 2007 7:03 am 
Newbie

Joined: Mon Jan 15, 2007 3:57 pm
Posts: 2
Location: Germany
Hi.

Thanks a lot for the fast reply!

We have a small monitoring Interface which delivers informations to some critical components (2nd level Cache, Connectionpool, Memory etc.).
We casually monitor those actual parameters and the logfiles.
We discovered a short time ago those "orphaned connections" and discovered parallel in catalina.out SQLExceptions saying "Connection reset".

We wanted to exclude the web app to produce those orphaned connections, since we never use pool-resets.
After your explanations I am pretty sure, that network errors cause the pool to declare the connections to be broken.
(ConnectionTesting is disabled by the way).

It also seemed that the network error was not always detected. One of our servers showed all connections to be busy and the log showed that the checkoutTimout fired all the time. So those connections were probably somehow not working correctly any more but no exception showed up to warn the connection pool. So they hung with their threads forever.

We already informed the hosting company about our network error guess and did not get any answers, yet, but the orphaned connections are gone since yesterday (servers are restarted at night).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.