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

Add retry mechanism to many database requests #217

Merged
merged 6 commits into from
Dec 5, 2024

Conversation

carmichaelong
Copy link
Contributor

Should help issues such as #189 and #192 that use the requests library. Requests are attempted one time and can fail if there are intermittent connectivity issues between the worker and database. This leads to errors that cannot be traced on the database, since it lost connection and cannot post to the database.

This adds a wrapper function to attempt multiple requests to these calls with an exponential backoff (e.g., attempt after 1 second, 2 seconds, 4 seconds, 16 seconds, 32 seconds).

@antoinefalisse @AlbertoCasasOrtiz I'm tagging you both (and would like a review from both) since it touches many important calls to the database. Some notes below:

Testing that's been done:

  • Added tests for the new wrapper function
  • Reprocessed a completed trial on dev. This, however, does not test all of the functions that have been updated.

Notes for review:

  • What other testing should be done (both now, before it gets merged into dev, and also before we merge into main)? At least a full session with new data collection on dev should be done before main.
  • This adds a tests folder, which required removing it from the .gitignore file. Will this mess up someone's workflow?
  • Would you like to see a smaller set of changes first? The change has been applied pretty broadly at this point, but we can use a smaller set of changes first and monitor if that's helpful.

@antoinefalisse
Copy link
Collaborator

@carmichaelong I've wanted something like this for so long!!! Thanks. I will review by the end of the week.

@antoinefalisse
Copy link
Collaborator

@carmichaelong LGTM

What other testing should be done (both now, before it gets merged into dev, and also before we merge into main)? At least a full session with new data collection on dev should be done before main.

I feel like a full session with new data on dev should be sufficient

This adds a tests folder, which required removing it from the .gitignore file. Will this mess up someone's workflow?

I don't think so, old stuff.

Would you like to see a smaller set of changes first? The change has been applied pretty broadly at this point, but we can use a smaller set of changes first and monitor if that's helpful.

I think it is good as is. I double checked that you changed all the requests.

Copy link
Collaborator

@AlbertoCasasOrtiz AlbertoCasasOrtiz left a comment

Choose a reason for hiding this comment

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

I just reviewed the code. LGTM!

@carmichaelong carmichaelong merged commit 43cd355 into dev Dec 5, 2024
@carmichaelong carmichaelong deleted the make-request-with-retry branch December 5, 2024 23:44
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