C3P0: unreturnedConnectionTimeout in production?

Monarch Wadia picture Monarch Wadia · Apr 13, 2015 · Viewed 9.3k times · Source

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

Steve Waldman picture Steve Waldman · Apr 20, 2015

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_clients (archived here). Then, 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.