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

Database resilience #143

Merged
merged 4 commits into from
Feb 19, 2018
Merged

Database resilience #143

merged 4 commits into from
Feb 19, 2018

Conversation

benjefferies
Copy link
Contributor

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

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.
@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)
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Done

Copy link
Contributor

@JamesGardiner JamesGardiner left a 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
Copy link
Contributor

@benjefferies
Copy link
Contributor Author

@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?

@JamesGardiner
Copy link
Contributor

@benjefferies considering it has had a green build will approve for now.

@benjefferies benjefferies merged commit 1673556 into master Feb 19, 2018
@benjefferies benjefferies deleted the database-resilience branch February 19, 2018 11:44
AndrewTorrance pushed a commit that referenced this pull request Feb 19, 2018
* master:
  Database resilience (#143)

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

Successfully merging this pull request may close these issues.

3 participants