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

Retry if S3 returns 500 #3962

Closed
carols10cents opened this issue Apr 27, 2017 · 7 comments · Fixed by #4032
Closed

Retry if S3 returns 500 #3962

carols10cents opened this issue Apr 27, 2017 · 7 comments · Fixed by #4032
Labels
E-easy Experience: Easy

Comments

@carols10cents
Copy link
Member

carols10cents commented Apr 27, 2017

Crates.io redirects to S3 for /download requests. Sometimes S3 returns a 500, and cargo should automatically retry.

Cargo has network retry logic, but right now it only retries if the error is "spurious".

We should tweak maybe_spurious to count 500 as something that should be retried, not sure which one of the curl errors corresponds to that or if we should just check the status code like this check does.

@alexcrichton
Copy link
Member

Currently the way curl operates a 500 isn't actually an error, but rather the perform function returns Ok(()), and then later when we extract the status code from the handle it says that it 500'd. Sort of like how if you .wait() on a process it'll return Ok even though the exit status may indicate failure.

I think the best way to solve this will be to first create a new error type:

enum CargoCurlError {
    Io(curl::Error),
    Code(u32),
}

Next implement the CargoError trait for this type as well as the network error trait. The closure here would then be updated to return this new error, moving the 500 checking logic into the closure. The implementation of the network error trait would then return "true" for "maybe_spurious" when the code is 500.

I'm gonna tag this as E-easy as I think it's a good starter bug, but if help is needed please just let me know!

@alexcrichton alexcrichton added the E-easy Experience: Easy label Apr 27, 2017
@0X1A
Copy link

0X1A commented Apr 27, 2017

@alexcrichton I'm willing to offer a PR for this

@alexcrichton
Copy link
Member

Awesome thanks @0X1A! Lemme know if you have any questions

@nagisa
Copy link
Member

nagisa commented May 4, 2017

500, 502, 503, 504 status codes are all “spurious”.

@aturon
Copy link
Member

aturon commented May 5, 2017

@0X1A Just checking in, are you still interested in working on this?

@0X1A
Copy link

0X1A commented May 7, 2017

@aturon Sorry, I've been a bit swamped recently, someone else is free to take this one

alexcrichton added a commit to alexcrichton/cargo that referenced this issue May 11, 2017
This commit implements auto-retry for downloading crates from crates.io whenever
a 5xx response is returned. This should help assist with automatic retries
whenever Cargo attempts to download directly from S3 but S3 returns a 500 error,
which is defined as "please retry again".

This logic may be a little eager to retry *all* 500 errors, but there's a
maximum cap on all retries regardless, so hopefully it doesn't result in too
many problems.

Closes rust-lang#3962
@alexcrichton
Copy link
Member

I've opened a PR for this at #4032

bors added a commit that referenced this issue May 11, 2017
Automatically retry HTTP requests returning 5xx

This commit implements auto-retry for downloading crates from crates.io whenever
a 5xx response is returned. This should help assist with automatic retries
whenever Cargo attempts to download directly from S3 but S3 returns a 500 error,
which is defined as "please retry again".

This logic may be a little eager to retry *all* 500 errors, but there's a
maximum cap on all retries regardless, so hopefully it doesn't result in too
many problems.

Closes #3962
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Experience: Easy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants