java - C3P0: unreturnedConnectionTimeout in production? - Stack Overflow
The parameter unreturnedConnectionTimeout
times out unreturned connections after a given period of time. I'm trying to decide whether I should use this in my production persistence.xml
? A big plus of using this is that the Connection Pool will be able to recover from leaky connections. A big minus is that leaky connections will be very difficult to detect.
Should I use unreturnedConnectionTimeout
in production applications? If yes, what should its value be? Are there any other pros/cons I should consider?
Answer:
You should debug your Connection leaks, and then not use unreturnedConnectionTimeout
in production, ideally.
To debug Connection leaks, set both unreturnedConnectionTimeout
and debugUnreturnedConnectionStackTraces
, see http://www.mchange.com/projects/c3p0/#configuring_to_debug_and_workaround_broken_clientsThen, when you have no more leaks, unset both of these parameters.
You would set unreturnedConnectionTimeout
in production mostly if for some reason you can't debug and fix the application whose Connections are leaking, in which case it's a reasonable workaround to just set unreturnedConnectionTimeout
and let c3p0 clean up what your application forgets to.