-
Notifications
You must be signed in to change notification settings - Fork 3
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
Database resilience #143
Database resilience #143
Conversation
Retry database connection on DatabaseError every 2s for up to 30s. This allows the app to be more robust when starting up. For instance when running up apps via docker-compose the app should be able to recover if the database is not up first.
secure_message/application.py
Outdated
@retry(retry_on_exception=retry_if_database_error, wait_fixed=2000, stop_max_delay=30000, wrap_exception=True) | ||
def create_db(app, app_config): | ||
database.db.init_app(app) | ||
logger.info('Starting Secure Message Service...', config=app_config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This log line can probably live outside of the create_db function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benjefferies this dependency isn't tested against 3.6
@JamesGardiner Fair point. There is this rholder/retrying#72 and https://travis-ci.org/rholder/retrying/builds/287235053?utm_source=github_status&utm_medium=notification. I have left a comment on the PR to see if it could be moved forward but whether we want to use it without 3.6 in the travis test matrix on master yet is the question? |
@benjefferies considering it has had a green build will approve for now. |
* master: Database resilience (#143) # Conflicts: # Pipfile.lock
What is the context of this PR?
Link to Trello card
Adding retry mechanism for when service is up before database. It means that the service will try every 2 seconds for 30 seconds to connect
How to review
Run service without database, start database after a few seconds and it should connect