-
Notifications
You must be signed in to change notification settings - Fork 252
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 on 5xx, error on 4xx #465
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, the retry policy is really dumb right now!
I suggest just a little change in logic to align our code to the one of the C# SDK.
log::error!("server returned error 500 status: {}", status); | ||
Box::new(response.validate(StatusCode::OK).await.unwrap_err()) | ||
} | ||
Err(error) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The C# SDK retries IOExceptions so we should retry here too (assuming we can discriminate the error to errors raised by the http policy).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you saying we should only retry IO related errors? Right now any error is retried.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sorry, that was what I meant... 😔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I can tackle that in another PR. This might require that we change the pipeline to not work with Box<dyn Error>
but with azure_core::Error
instead.
@MindFlavor @heaths I've made a change to this PR where we now treat any 2xx (and for that matter any 3xx or 1xx if those should ever happen to be returned) as successes. We are now validating in the retry policy that we get a successful response and if not either retry (if it's a response code we hard code as being a retry status code) or immediately return an error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat! Thank you! ❤️
} | ||
Err(error) => { | ||
log::debug!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 67 uses log::error
for the same message. Should these be consistent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be retried (and hopefully succeed on retry) where as line 67 will be returned to the user as an error. Therefore, line 67 represents an error that the user will definitely handle while hopefully this line is just a transient state.
An attempt to fix #464
The policy now works as following:
Ok(response)
Err(HttpError::UnexpectedStatusCode)
Questions: