Why is #verify_active_connections! :nodoc: ?

Hi, I’ve just got a quick question.

How come ActiveRecord::ConnectionAdapters::ConnectionHandler#verify_active_connections! is marked with :nodoc: ?

I understand that this is used internally (depending upon an application’s configuration?) on every request (?) to clear out old, stale database connections. All this to prevent the old, classic “MySQL server has gone away…” types of exceptions with applications that sometimes see very little usage.

However, from my searching in this (and the Ruby on Rails: Talk) list(s), I’m also under the impression that someone using ActiveRecord without rails might have to call this manually. In my case, I’m setting up a resque (https://github.com/defunkt/resque) system and might have my worker(s) use ActiveRecord but not the full rails environment. I might have a worker go long stretches without any action, giving me stale connections in my connection pool. To avoid any problems, I found a gem, resque-ensure-connected (https://github.com/wireframe/resque-ensure-connected) that apparently just calls #verify_active_connections! in order to solve this problem.

So, why do I care? Because while reading the source of the resque-ensure-connected gem I realized it’s solution literally just comes down to simply calling #verify_active_connections!. I was curious about this method and tried to look it up in the docs. It wasn’t there. I don’t like using stuff that relies on unpublished “internals” in case said internal method/API changes on me down the line.

So, is this a stable, public API method? If so, may we allow it to be documented please?

If not, what should someone in my situation use?

Thanks for your time!

1 Like