Routing: Fixes LengthAware comparer wiring across env var and cold-start CollectionRoutingMap paths#5866
Merged
Conversation
- ConfigurationManager.IsLengthAwareRangeComparatorEnabled() now defaults true in all non-INTERNAL builds (was only true in PREVIEW). This makes AZURE_COSMOS_USE_LENGTH_AWARE_RANGE_COMPARATOR=false work in GA SDK. - CosmosClientOptions.UseLengthAwareRangeComparer now reads from ConfigurationManager instead of a hardcoded #if !INTERNAL literal. This wires PartitionKeyRangeCache.TryCombine to the env var so all three LengthAware usage sites (TryCombine, QueryRangeUtils, PartitionRoutingHelper) can be disabled via a single env var. Customer mitigation: set AZURE_COSMOS_USE_LENGTH_AWARE_RANGE_COMPARATOR=false to disable LengthAware routing and avoid silent empty query results on HPK containers after a partition split. Fixes: #5859 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
fee1997 to
03314d4
Compare
Covers the AZURE_COSMOS_USE_LENGTH_AWARE_RANGE_COMPARATOR env var end-to-end: ConfigurationManager -> CosmosClientOptions -> CosmosClient -> DocumentClient. 3 parametric tests (10 invocations): - ConfigurationManager.IsLengthAwareRangeComparatorEnabled() for unset / false / true - CosmosClientOptions default for unset / false / true - Real CosmosClient construction for unset / false / true and explicit-option-wins Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
03314d4 to
06e6653
Compare
…ingMap PR #5551 wired CosmosClientOptions.UseLengthAwareRangeComparer to the TryCombine refresh callsite in PartitionKeyRangeCache but left a hardcoded false at the cold-start TryCreateCompleteRoutingMap callsite. That meant the first CollectionRoutingMap for every container in every CosmosClient was always built with the regular Range<string>.MinComparer/MaxComparer regardless of the env var or explicit option, since CollectionRoutingMap bakes the comparer choice once at construction. This change propagates the configured value to both callsites and pins the cold-start contract with a parametric reflection-based regression test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
Wires \AZURE_COSMOS_USE_LENGTH_AWARE_RANGE_COMPARATOR\ env var to all LengthAware usage sites so customers can disable it as a mitigation for the HPK silent empty query issue (#5859).
Problem
Two disconnected controls existed for the LengthAware range comparer:
Changes
ConfigurationManager.IsLengthAwareRangeComparatorEnabled()
CosmosClientOptions.UseLengthAwareRangeComparer
All LengthAware sites unified under single env var
Customer Mitigation
Set \AZURE_COSMOS_USE_LENGTH_AWARE_RANGE_COMPARATOR=false\ to disable LengthAware routing.
Related: #5859, #5850