Skip to content

HPK: Add internal CosmosClientOptions flag UseLengthAwareRangeComparer for length aware range comparer rollout.#5551

Merged
ananth7592 merged 4 commits intomasterfrom
ananth/hpk-cosmos-client-options
Jan 26, 2026
Merged

HPK: Add internal CosmosClientOptions flag UseLengthAwareRangeComparer for length aware range comparer rollout.#5551
ananth7592 merged 4 commits intomasterfrom
ananth/hpk-cosmos-client-options

Conversation

@ananth7592
Copy link
Copy Markdown
Contributor

Description

This change adds an internal-only CosmosClientOptions.UseLengthAwareRangeComparer property to enable controlled rollout of the HPK EPK range comparator fix. This is useful for both V3 and compute gateway rollout control.

Background:
The HPK EPK normalization fix (released in V3 Preview 3.56.0-preview.0) currently uses an environment variable feature flag (default=True). However, Compute doesn't support environment variables - it only supports TenantConfigurationProvider and CosmosClientOptions for feature flag control.

This Change:

  • Adds internal bool UseLengthAwareRangeComparer to CosmosClientOptions (default=true)
  • Threads the parameter through the entire query pipeline to QueryRangeUtils
  • Updates all test call sites to explicitly pass useLengthAwareRangeComparer: true
  • No public API surface changes (internal-only property)

Type of change

  • No public API surface changes (internal-only property)

Closing issues

To automatically close an issue: closes #IssueNumber

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Please follow the required format: "[Internal] Category: (Adds|Fixes|Refactors|Removes) Description"

Internal should be used for PRs that have no customer impact. This flag is used to help generate the changelog to know which PRs should be included. Examples:
Diagnostics: Adds GetElapsedClientLatency to CosmosDiagnostics
PartitionKey: Fixes null reference when using default(PartitionKey)
[v4] Client Encryption: Refactors code to external project
[Internal] Query: Adds code generator for CosmosNumbers for easy additions in the future.

@ananth7592 ananth7592 force-pushed the ananth/hpk-cosmos-client-options branch 8 times, most recently from 6576efb to bea785c Compare January 13, 2026 20:53
@ananth7592 ananth7592 requested a review from Copilot January 14, 2026 00:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds an internal CosmosClientOptions.UseLengthAwareRangeComparer flag to enable controlled rollout of the HPK EPK range comparator fix. The change threads this boolean parameter through the entire query pipeline from CosmosClientOptions down to QueryRangeUtils and CollectionRoutingMap, where it controls whether to use length-aware or legacy range comparers for EPK range comparisons.

Changes:

  • Added internal UseLengthAwareRangeComparer property to CosmosClientOptions (default=true)
  • Threaded the parameter through DocumentClient, ClientContextCore, PartitionKeyRangeCache, CollectionRoutingMap, and the entire query pipeline
  • Updated all test call sites to pass the new parameter explicitly

Reviewed changes

Copilot reviewed 46 out of 46 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
CosmosClientOptions.cs Added internal property UseLengthAwareRangeComparer with documentation
DocumentClient.cs Added parameter to constructor and passed to PartitionKeyRangeCache
ClientContextCore.cs Threaded parameter from client options to DocumentClient
PartitionKeyRangeCache.cs Added parameter to constructor and used in TryCombine calls
CollectionRoutingMap.cs Updated constructor and methods to accept and use the parameter
QueryRangeUtils.cs Added parameter to methods for comparator selection
Query/v3Query/QueryIterator.cs Passed parameter from client options to query context
Query/v3Query/CosmosQueryClientCore.cs Passed parameter to QueryRangeUtils
Query pipeline files Threaded parameter through all pipeline stages
Test files (various) Updated mock constructors and test call sites with new parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Microsoft.Azure.Cosmos/src/Routing/PartitionKeyRangeCache.cs
@ananth7592 ananth7592 force-pushed the ananth/hpk-cosmos-client-options branch from bea785c to 3ecdf30 Compare January 14, 2026 00:36
@ananth7592 ananth7592 force-pushed the ananth/hpk-cosmos-client-options branch 3 times, most recently from 26988a6 to a4a39a8 Compare January 20, 2026 21:53
…parer rollout control.

This change adds an internal-only CosmosClientOptions.UseLengthAwareRangeComparer
property to enable controlled rollout of the HPK EPK range comparator fix.
This is useful for both V3 and compute gatway rollout control.

Background:
The HPK EPK normalization fix (released in V3 Preview 3.56.0-preview.0) currently
uses an environment variable feature flag (default=True). However, Compute doesn't
support environment variables - it only supports TenantConfigurationProvider and
CosmosClientOptions for feature flag control.

This Change:
- Adds internal bool UseLengthAwareRangeComparer to CosmosClientOptions (default=true)
- Threads the parameter through the entire query pipeline to QueryRangeUtils
- Updates all test call sites to explicitly pass useLengthAwareRangeComparer: true
- No public API surface changes (internal-only property)
Comment thread Microsoft.Azure.Cosmos/src/CosmosClientOptions.cs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants