Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

debugging loss of connections using 'debugUnreturnedConnectionStackTraces'

I am working on fixing connection timeouts issues for a project that iam working on. we use c3p0 to manage the connection pool and hibernate as the orm tool. we also use spring.

To find if there any unreturned connections, i have set debugUnreturnedConnectionStackTraces to true in my c3p0 configuration(NOT in c3p0 properties).

Is there anything else that I need to do. Do I have to add anything to my lod4j.properties also or is it just enough to set debugUnreturnedConnectionStackTraces to true?

Also, should i set debugUnreturnedConnectionStackTraces to true in c3p0 properties?

Thanks for the help

like image 928
Npa Avatar asked Aug 03 '12 15:08

Npa


2 Answers

Expanding a bit on Corey's answer:

If unreturnedConnectionTimeout is positive and debugUnreturnedConnectionStackTraces is set to true, then the stack traces that generated unreturned Exceptions will be logged at INFO level by the logger "com.mchange.v2.resourcepool.BasicResourcePool".

Often people log anything above INFO level from all loggers, so these stack traces just appear in your logs. But if you don't see them, do check your logging configuration to make sure messages at INFO from that logger are not filtered.

Note that debugUnreturnedConnectionStackTraces will do NOTHING if unreturnedConnectionTimeout is not also set.

See

http://www.mchange.com/projects/c3p0/#unreturnedConnectionTimeout

http://www.mchange.com/projects/c3p0/#debugUnreturnedConnectionStackTraces

I hope this helps!

p.s. it doesn't matter how you set these properties, as long as they are properly set. c3p0 dumps pool configurations at INFO on pool initiation; check your logs to make sure that, however you are trying to set parameters, you have the configuarion you expect. Alternatively you can use JMX to inspect parameters.

like image 114
Steve Waldman Avatar answered Sep 24 '22 23:09

Steve Waldman


Personally I normally add both of the following 2 lines to my hibernate.cfg.xml

<property name="hibernate.c3p0.unreturnedConnectionTimeout">60</property>
<property name="hibernate.c3p0.debugUnreturnedConnectionStackTraces">true</property>

I believe the default value on the timeout is 0 and I'm not sure how that is supposed to work.

like image 35
Corey Scott Avatar answered Sep 23 '22 23:09

Corey Scott