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

Effective Preferred Locations #39714

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

tvaron3
Copy link
Member

@tvaron3 tvaron3 commented Feb 13, 2025

Background

Preferred locations is an option set on the cosmos client. It indicates to the SDK in what priority to route requests.
Example

  • Account Regions (these are the ones that appear in portal): East US, East US 2, West US, West US 2
  • Preferred Locations: East US, West US, West US 2
  • Read: Requests will be routed to East US first. If for some reason, the requests fail with a retrieable error or status code, then the requests will be retried on West US. If the requests fail again, then the requests will be retried on West US 2. Note that requests will never go to East US 2 because it is not part of the preferred locations.
  • Writes: For single write accounts, writes will go to the write region regardless of preferred locations set. For multi write accounts, writes will go to the preferred locations in order.

Problem

Previously to this pr, if no preferred locations were passed into the cosmos client then the SDK would route requests only to the hub region for single write accounts. For multi-write accounts, the SDK would route requests only to the endpoint passed in through the client. This is undesirable because it would be opting out customers by default to an availability feature.

Solution

If no preferred locations and the global endpoint are passed into the cosmos client, then the SDK will populate it using the account regions. If a regional endpoint is passed in, the existing behavior will be kept.

Note: This is a breaking change for customers using bounded staleness consistency.

Relevant Issue

@tvaron3 tvaron3 requested review from annatisch and a team as code owners February 13, 2025 15:21
@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

@tvaron3
Copy link
Member Author

tvaron3 commented Feb 13, 2025

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tvaron3
Copy link
Member Author

tvaron3 commented Feb 13, 2025

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@simorenoh simorenoh left a comment

Choose a reason for hiding this comment

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

love the way the test is made as well, thanks Tomas!

@jeet1995
Copy link
Member

All requests will be routed to East US first. If for some reason, the requests fail with a retriable error or status code, then the requests will be retried on West US. If the requests fail again, then the requests will be retried on West US 2. Note that requests will never go to East US 2 because it is not part of the preferred locations.

I think you need to disambiguate between how reads and writes behave.

@jeet1995
Copy link
Member

jeet1995 commented Feb 20, 2025

Another aspect is testing - it would be good to add coverage in our retry policy tests when the client isn't configured with preferred locations - 503, 408, 404:1002 - all have cross-region retry semantics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

5 participants