Skip to content

[Cosmos] Service Request and Response retries - #39396

Merged
Kushagra Thapar (kushagraThapar) merged 43 commits into
hotfix/azure-cosmos/4.9.2b2from
service-reetries
Jan 26, 2025
Merged

Kushagra Thapar (kushagraThapar) merged 43 commits into
hotfix/azure-cosmos/4.9.2b2from
service-reetries

Conversation

@simorenoh

@simorenoh Simon Moreno (simorenoh) commented Jan 24, 2025 •

Copy link
Copy Markdown
Member

This PR introduces cross-regional retries for requests failing to reach the service, or where the service failed to provide a response.

Changes
In the case of a ServiceRequestError, where we know the request didn't reach the service, we know it is safe to retry. In this case we don't have any filters for the operation, and retry once in each relevant preferred region location before raising the exception to the user.

In the case of a ServiceResponseError, where the service was not able to give a response, we filter on these being only exceptions that have to do with unavailability due to timeouts with the service. If that's the case, then we filter on these requests being exclusively document-level read operations, since these are the only ones we know we can retry safely upon not being able to ascertain the output of the request sent. These are retried in the relevant available preferred read locations.

This PR also contains a bugfix to ensure that even if preferred regions are not present in the current account regions, we don't attempt to go into them.

Testing
Manual testing for the first set of changes has been done by reducing the connection timeout on requests after the client is initialized and fetches the database account information. Added tests mocking this functionality.

Manual testing for the bugfix has been done as well, where we see that even though the most_preferred_endpoint is one that is no longer present in the account, we don't attempt to go into it when resolving the service endpoint.

@azure-sdk

Copy link
Copy Markdown
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

azure-cosmos

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants