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
Comments
+1 (it creates a lot of not transparent problems: for example) |
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. |
The defaults for both 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. |
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)
The text was updated successfully, but these errors were encountered: