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

Extract DeleteCrateFromStorage background job #9549

Merged
merged 3 commits into from
Oct 4, 2024

Conversation

Turbo87
Copy link
Member

@Turbo87 Turbo87 commented Oct 1, 2024

@Turbo87 Turbo87 added C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear A-backend ⚙️ labels Oct 1, 2024
Comment on lines +28 to +45
try_join!(
async {
info!("{name}: Deleting crate files from S3…");
let result = ctx.storage.delete_all_crate_files(name).await;
result.context("Failed to delete crate files from S3")
},
async {
info!("{name}: Deleting readme files from S3…");
let result = ctx.storage.delete_all_readmes(name).await;
result.context("Failed to delete readme files from S3")
},
async {
info!("{name}: Deleting RSS feed from S3…");
let feed_id = FeedId::Crate { name };
let result = ctx.storage.delete_feed(&feed_id).await;
result.context("Failed to delete RSS feed from S3")
}
)?;
Copy link
Member Author

Choose a reason for hiding this comment

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

is it sufficient for this to be in one job or should it be split into multiple jobs that can be retried individually if they fail? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, what would happen if one of these failed?

Copy link
Member Author

Choose a reason for hiding this comment

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

try_join!() cancels the other runnings tasks if one of them fails. it then returns the error, which will make the job fail and will cause it to be retried a little later. AFAIU all of the steps in this job are idempotent though, so retrying isn't a big deal. the job does not perform CDN invalidations yet though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's say task 1 succeeds first, but task 2 fails, so it cancels task 3. What will the state of task 1 be after all? If it remains done, is it safe to retry?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think if every job could be retried even if it's already completed, this wouldn't be a problem.

Copy link
Member Author

Choose a reason for hiding this comment

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

If it remains done, is it safe to retry?

yes, as far as I understand this shouldn't be an issue. I guess splitting it up is probably unnecessary over-engineering 😅

@Turbo87 Turbo87 requested a review from a team October 1, 2024 11:48
Copy link

codecov bot commented Oct 1, 2024

Codecov Report

Attention: Patch coverage is 3.03030% with 32 lines in your changes missing coverage. Please review.

Project coverage is 89.07%. Comparing base (3c970a1) to head (e021fe8).
Report is 26 commits behind head on main.

Files with missing lines Patch % Lines
src/worker/jobs/delete_crate.rs 0.00% 28 Missing ⚠️
src/admin/delete_crate.rs 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9549      +/-   ##
==========================================
- Coverage   89.11%   89.07%   -0.04%     
==========================================
  Files         285      286       +1     
  Lines       28920    28935      +15     
==========================================
+ Hits        25773    25775       +2     
- Misses       3147     3160      +13     

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

@Turbo87 Turbo87 merged commit 2e5a4fe into rust-lang:main Oct 4, 2024
10 checks passed
@Turbo87 Turbo87 deleted the delete-crate-job branch October 4, 2024 08:05
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