Skip to content
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

Reconnecting in pool #390

Closed
ghost opened this issue Sep 1, 2016 · 3 comments
Closed

Reconnecting in pool #390

ghost opened this issue Sep 1, 2016 · 3 comments
Labels

Comments

@ghost
Copy link

ghost commented Sep 1, 2016

Mysql2 pool keeps unused connections (they appear in SHOW PROCESSLIST; as in Sleep state)
but what will happen when one of these connection gets broken? mysql2 pool will remove them or reconnect?

@sidorares
Copy link
Owner

yes, the connection is removed if it can't be reused ( network error, server forcibly closed, client ended connection etc ). Unused connections are obviously not disconnected (this is the whole point of pool) but we might add an option "disconnect unused connection if idle for more than certain time" - see #321

Currently there is no option to keep pool in "pre-heated" state (minimum number of open connections) - you have at most connectionLimit connections open, zero initially and the number of open connections may grow (if you ask for connection and all currently open connections are in use) or decrease (if connection dies)

@sytpb
Copy link

sytpb commented May 31, 2024

if the server forcibly closed, what happen of Mysql2 pool , what should we do in code to keep the query or insert normal ?
or maybe we shouldn't do anything , Mysql2 pool will manage it ?

@sidorares
Copy link
Owner

if the server forcibly closed, what happen of Mysql2 pool , what should we do in code to keep the query or insert normal ? or maybe we shouldn't do anything , Mysql2 pool will manage it ?

any active connections will be closed in that case ( and unfinished commands with end with error ). Next time you'll try to get connection from the pool it'll try to connect a new one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants