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

mysql pool recycle default #91

Closed
asergeyev opened this issue Jul 27, 2012 · 3 comments
Closed

mysql pool recycle default #91

asergeyev opened this issue Jul 27, 2012 · 3 comments

Comments

@asergeyev
Copy link

there is default for mysql driver in flask-sqlalchemy
options.setdefault('pool_recycle', 7200)

Most servers will timeout client connection in 1 hour IMO it's better to use this as a default value and let people change it to longer times when appropriate.

(....there is another caveat right now - if your mysql server got restarted there is nothing that would catch exception and try to reconnect to serve current request, I wonder if that exception would be possible to catch in lib, not inside of the application code)

@kkamkou
Copy link

kkamkou commented Oct 8, 2015

+1 (it creates a lot of not transparent problems: for example)

@davidism
Copy link
Member

davidism commented Oct 9, 2015

According to the Flask-SQLAlchemy docs and the SQLAlchemy docs, MySQL recycles connections every 8 hours by default, and Flask-SQLAlchemy sets this to 2 hours. I've seen plenty of questions about MySQL timeouts on SO, but I'd be more inclined to change this if you could point to a definitive statement that the default is 1 hour.

SQLAlchemy also describes some ways that connections can be invalidated. I'm not sure if these sorts of things should be worked into Flask-SQLAlchemy.

@immunda
Copy link
Contributor

immunda commented Nov 25, 2015

The defaults for both interactive_timeout and wait_timeout are 8 hours. I appreciate that some folks may have providers with unusual DB configurations, but I don't think that's the responsibility of this library to solve, as it wouldn't provide a general solution.

I've also read through that SO post and whilst valid, without a running and complete configuration to be tested against, there's no way to determine whether that particular problem is even caused by this.

@immunda immunda closed this as completed Nov 25, 2015
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants