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 policy unable to react to unexpected HTTP status codes #464

Closed
rylev opened this issue Oct 29, 2021 · 1 comment · Fixed by #465
Closed

Retry policy unable to react to unexpected HTTP status codes #464

rylev opened this issue Oct 29, 2021 · 1 comment · Fixed by #465
Labels
Azure.Core The azure_core crate

Comments

@rylev
Copy link
Contributor

rylev commented Oct 29, 2021

Currently we validate HTTP status codes outside of the pipeline (e.g., here. This means the retry policy has no way of retrying requests that failed by returning an HTTP status code that represents an error (e.g., 500s).

Some questions:

  • Should the retry policy inspect the incoming response and retry if the HTTP status code is 5xx?
  • Should the client immediately error (i.e., not retry) if the error is 4xx?
  • Should we validate the status code if it is 2xx or 3xx? For example, if the Cosmos create database endpoint returns 200 instead of 201, should we error? We currently will, but this seems very restrictive.

cc @heaths @MindFlavor

@heaths
Copy link
Member

heaths commented Oct 29, 2021

When in doubt, I like to check with .NET: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/src/Pipeline/Internal/RetryPolicy.cs

Apart from retrying based on headers (we also have plans to allow customization via the response classifier, since some services like Key Vault uses a nonstandard header like "RetryAfter" (no dash), it does support an overridable check: https://github.com/Azure/azure-sdk-for-net/blob/04b28e36433fe4ada5d75c9bf2309e4503c96960/sdk/core/Azure.Core/src/ResponseClassifier.cs#L45

By default, it retries on any RequestFailedException, which in turn is thrown for any non-success: https://github.com/Azure/azure-sdk-for-net/blob/04b28e36433fe4ada5d75c9bf2309e4503c96960/sdk/core/Azure.Core/src/Pipeline/HttpClientTransport.cs#L127-L130 (seems HttpClient does this for any 400- or 500-level error).

Though it's not used by default (it was, and probably still used by overrides), we also have these retriable defaults: https://github.com/Azure/azure-sdk-for-net/blob/04b28e36433fe4ada5d75c9bf2309e4503c96960/sdk/core/Azure.Core/src/ResponseClassifier.cs#L17-L31

@rylev rylev closed this as completed in #465 Nov 1, 2021
@heaths heaths added the Azure.Core The azure_core crate label Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core The azure_core crate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants