LocationCache: Fixes read fallback to use WriteEndpoints[0] when PPAF enabled and all regions excluded#5823
Open
ananth7592 wants to merge 1 commit intomainfrom
Open
LocationCache: Fixes read fallback to use WriteEndpoints[0] when PPAF enabled and all regions excluded#5823ananth7592 wants to merge 1 commit intomainfrom
ananth7592 wants to merge 1 commit intomainfrom
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
…ind PPAF When ExcludeRegions filters out all preferred read regions and PPAF (Partition Level Failover) is enabled, GetApplicableEndpoints now falls back to WriteEndpoints[0] (dynamic, tracks current write region) instead of this.defaultEndpoint (static, region-agnostic URI set once at init). The fix is gated behind isPartitionLevelFailoverEnabled (Func<bool>) wired from ConnectionPolicy.EnablePartitionLevelFailover through GlobalEndpointManager, supporting dynamic enablement per PR #5310. When PPAF is disabled, original behavior (defaultEndpoint fallback) is preserved. Fixes #5821 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
8b6cfce to
038e757
Compare
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Member
|
Shall we also update the verbaige in the |
| // never updated after init). This aligns with UpdateLocationCache which already uses | ||
| // WriteEndpoints[0] as the ReadEndpoints fallback, and matches Java/Python SDK behavior. | ||
| Uri fallbackEndpoint = (isReadRequest && this.isPartitionLevelFailoverEnabled?.Invoke() == true) | ||
| ? databaseAccountLocationsInfoSnapshot.WriteEndpoints[0] |
Member
There was a problem hiding this comment.
Shall we always pick the databaseAccountLocationsInfoSnapshot.WriteEndpoints[0] or if we should condition it to check for the PPAF cache override as well? If the override is present, then always pick that endpoint as the hub endpoint.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When ApplicationPreferredRegions == ExcludeRegions, LocationCache.GetApplicableEndpoints falls back to his.defaultEndpoint — a static, region-agnostic URI set once at init and never updated. After a write region (hub) switch, the GlobalAddressResolver's cached EndpointCache for this default endpoint has a stale AddressResolver.location, causing incorrect region tracking in diagnostics, per-partition routing, and retry logic.
Fix
When PPAF (IsPartitionLevelFailoverEnabled) is enabled, GetApplicableEndpoints now uses WriteEndpoints[0] (dynamic, tracks current write region) as the read fallback instead of his.defaultEndpoint.
This aligns with:
PPAF Gating
The fix is gated behind Func isPartitionLevelFailoverEnabled wired from ConnectionPolicy.EnablePartitionLevelFailover through GlobalEndpointManager, supporting dynamic enablement per PR #5310. When PPAF is disabled, original behavior (defaultEndpoint fallback) is preserved.
Changes
Testing
All 94 LocationCacheTests pass.
Fixes #5821