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

fix: prevent tasks dying from temporary loss of db connection #3674

Conversation

matthewelwell
Copy link
Contributor

@matthewelwell matthewelwell commented Mar 26, 2024

Changes

Fixes issue where threads die from a temporary loss of connection to the database by catching DatabaseError and logging.

How did you test this code?

Added a unit test to verify that the exception is handled and the correct logs are written.

Copy link

vercel bot commented Mar 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 26, 2024 2:41pm
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 26, 2024 2:41pm
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 26, 2024 2:41pm

@codecov-commenter
Copy link

codecov-commenter commented Mar 26, 2024

Codecov Report

Attention: Patch coverage is 95.34884% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 95.90%. Comparing base (21cc2d3) to head (e49b588).
Report is 6 commits behind head on main.

Files Patch % Lines
api/task_processor/threads.py 80.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3674      +/-   ##
==========================================
+ Coverage   95.86%   95.90%   +0.03%     
==========================================
  Files        1099     1100       +1     
  Lines       34422    34458      +36     
==========================================
+ Hits        33000    33047      +47     
+ Misses       1422     1411      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@matthewelwell matthewelwell marked this pull request as ready for review March 26, 2024 14:06
@matthewelwell matthewelwell requested review from a team and khvn26 and removed request for a team March 26, 2024 14:06
@matthewelwell matthewelwell changed the title fix: prevent tasks dying from temporary loss of db connection (WIP) fix: prevent tasks dying from temporary loss of db connection Mar 26, 2024
Copy link
Member

@khvn26 khvn26 left a comment

Choose a reason for hiding this comment

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

LGTM.

I'd love to see a test with less mocking (e.g. with db fixture taken out), but it's probably not worth the hassle. In case of errors different than DatabaseError, we'll take it as it comes I guess.

@matthewelwell matthewelwell added this pull request to the merge queue Mar 27, 2024
Merged via the queue into main with commit b872a6c Mar 27, 2024
23 checks passed
@matthewelwell matthewelwell deleted the fix/prevent-tasks-dying-from-temporary-loss-of-db-connection branch March 27, 2024 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants