How should reaper handle dead connections in the DB pool? #14302

lightswitch05 opened this Issue Mar 6, 2014 · 3 comments


None yet
4 participants

For the full background story on my database connection issues, please see rsim/oracle-enhanced#420.

My database connections die after an hour of inactivity. The dead connections are never discovered until they are needed, causing the request to hang for a full 15 minutes before the connections are refreshed. I enabled reaper with a reaping_frequency of 2.5 minutes to prevent my database connection pool from going stale - unfortunately Reaper is uninterested in my dead connection.

For a connection to become reaped - it must be marked as in_use - line 396. Because my application is properly closing and returning connections to the pool, reaper never finds any stale connections. Shouldn't reaper be concerned with all the connections in the pool and not only the ones that were returned improperly?


fxn commented Mar 6, 2014


matthewd commented Mar 7, 2014

Yeah, the reaper is only intended to clean up after misbehaving threads... a connection that's not in_use should be addressed by #verify! when it's being checked out.

Are you saying that one of #active? or #reconnect! hangs when called on a disconnected connection? That would certainly be Not Good...

From a quick browse (and without a suitable setup in which to confirm the theory), my guess is that the hang is in OCI8#logoff, via OCI8EnhancedAutoRecover#reset!, via OracleEnhancedOCIConnection#reset!, via OracleEnhancedAdapter#reconnect!. That seems to end up doing rather a lot for a connection we know isn't there -- and without any apparent timeout.

@matthewd I'm actually using JDBC with Oracle Enhanced - OracleEnhancedJDBCConnection.

I opened this ticket to get a firm answer on Reaper's purpose. From the documentation I got the idea it was meant to clean up all bad connections, and not just leaked ones from poor coding or unreliable threads. But, apparently it is doing exactly what it was meant to do, so this ticket can now be closed. I will continue tracking down the cause of the 15 minute hang from the original ticket rsim/oracle-enhanced#420.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment