Skip to content

worker: Replace r2d2 with deadpool #8385

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

Merged
merged 8 commits into from
Apr 8, 2024
Merged

Conversation

Turbo87
Copy link
Member

@Turbo87 Turbo87 commented Mar 29, 2024

This PR ports all of our background worker jobs to use the async database connection pool (based on the deadpool crate) instead of r2d2 (which does not support diesel-async).

This was initially causing failing and flaky tests, but those issues got resolved by:

@Turbo87 Turbo87 added C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear A-backend ⚙️ labels Mar 29, 2024
@Turbo87 Turbo87 requested a review from a team March 29, 2024 15:42
@Turbo87 Turbo87 force-pushed the deadpool-worker branch 2 times, most recently from 1f55578 to e9b0c9d Compare March 29, 2024 15:50
Copy link

codecov bot commented Mar 29, 2024

Codecov Report

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

Project coverage is 87.62%. Comparing base (0a04e27) to head (e6bbda7).
Report is 2 commits behind head on main.

Files Patch % Lines
src/worker/jobs/daily_db_maintenance.rs 0.00% 4 Missing ⚠️
src/worker/jobs/downloads/process_log.rs 91.30% 2 Missing ⚠️
src/worker/jobs/git.rs 60.00% 2 Missing ⚠️
src/worker/jobs/downloads/queue/job.rs 92.30% 1 Missing ⚠️
src/worker/jobs/readmes.rs 83.33% 1 Missing ⚠️
src/worker/jobs/typosquat.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8385      +/-   ##
==========================================
- Coverage   87.64%   87.62%   -0.03%     
==========================================
  Files         272      272              
  Lines       26342    26333       -9     
==========================================
- Hits        23087    23073      -14     
- Misses       3255     3260       +5     

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

Copy link
Contributor

@LawnGnome LawnGnome left a comment

Choose a reason for hiding this comment

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

LGTM.

A couple of non-blocking notes, but nothing substantive.

Comment on lines +352 to +355
let already_processed = conn
.interact(move |conn| already_processed_inner(path, conn))
.await
.map_err(|err| anyhow!(err.to_string()))??;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth us providing a trait to wrap this pattern, since it's coming up in every job?

Copy link
Member Author

Choose a reason for hiding this comment

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

you mean something like .interact_anyhow(...)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend ⚙️ C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants