-
Notifications
You must be signed in to change notification settings - Fork 8
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
Dealing with DB disconnections #6
Comments
Has anyone looked into either fixing this or some workaround that prevents it? |
* Wrap all database operations (including reads) in an SQLAlchemy transaction per http://docs.sqlalchemy.org/en/latest/orm/session_basics.html#when-do-i-construct-a-session-when-do-i-commit-it-and-when-do-i-close-it * Add configuration parameters to set the pool_recycle and pool_pre_ping engine parameters defaults are to recycle in 30 minutes and to always ping
I've got an experimental patch for this at I've incorporated it into my bot; it runs in AWS and was hitting this about once a week, so it'll be a couple of weeks before I can be sure that the fix is good, but of course comments in the mean time are most welcome. |
* Wrap all database operations (including reads) in an SQLAlchemy transaction per http://docs.sqlalchemy.org/en/latest/orm/session_basics.html#when-do-i-construct-a-session-when-do-i-commit-it-and-when-do-i-close-it * Add configuration parameters to set the pool_recycle and pool_pre_ping engine parameters defaults are to recycle in 30 minutes and to always ping
We use this backed onto a Multi-AZ PostgreSQL on RDS. When the DB fails over during updates/etc, errbot dies.
Which is ok, there's one error when the PG instance is switched. But it never reconnects, and every command produces output like:
As far as I can tell, every method in SQLStorage that access the DB should be wrapped in a session transaction (not just the methods that write to the DB), as discussed in the SQLAlchemy docs. No idea why
@session_scope
isn't part of SQLAlchemy, but implementing that would work I think?Might also be worth adding
pool_size=1, pool_recycle=300
or something to the default engine too as a bit of added resiliency.The text was updated successfully, but these errors were encountered: