-
Notifications
You must be signed in to change notification settings - Fork 143
-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for recycling connections / setting a maximum age on connections #91
Comments
The readme says connections must be self-healing and I have no plans to change that. |
I'm not asking for healing support, I'm asking for pre-emptive closing support, which is not provided by any of the libraries that you cite as "self-healing" in the readme. If you're really uninterested in such functionality, I'll just fork, but I figured I'd ask first. |
I don't know of anyone else asking for that functionality so I think forking is the right thing to do here.
|
@Roguelazer would this aid in recycling |
@mperham I'm running into this issue as well. def connection
return Mysql2::Client.new(options)
end
def pool
@db ||= ConnectionPool.new(size: 5, timeout: 5){ connection }
end
def get_users
pool.with do |db|
return db.query("SELECT * from users")
end
end the db.query line is throwing the exception. How can I tell connection_pool "this connection is dead, throw it away and grab another one" with the existing code? |
@daveroberts You cannot. From the readme:
|
It would be nice to be able to set a maximum lifetime for a connection and have it automatically destroyed on checkin once it exceeds that lifetime, so that we can forcibly recycle connections. The most pressing use-case for this is when the resource being connected to is behind a layer 4 (tcp) load balancer and you want to ensure that connections will pick up new hosts periodically. Most other connection pooling libraries that I've used have this functionality, and it seems self-evidently valuable to me.
This would require some fairly invasive changes (e.g., maintaining metadata about each connection at creation time so that we know how old it is), so I figured I'd run the concept by you before writing up a patch.
The text was updated successfully, but these errors were encountered: