Skip to content

azcosmos: cold partition range cache refresh rejects duplicate range revisions #27246

Description

@Tonkpils

Bug Report

  • Import path: github.com/Azure/azure-sdk-for-go/sdk/data/azcosmos
  • SDK version: v1.5.0
  • Go version: go1.26.3

What happened?

A new Cosmos client can intermittently fail its first ReadFeedRanges or ReadChangeFeed call against a container undergoing physical partition splits.

The partition-range change feed can return multiple revisions of the same range ID with different boundaries. The SDK then rejects the routing map because the range appears to overlap itself:

partition key range cache refresh failed: service returned an incomplete set
of ranges (... issue: overlap between range id=X (...) and range id=X (...))

The affected path is:

getPartitionKeyRanges
  -> partitionKeyRangeCache.getRoutingMap
  -> refreshEntryDetached
  -> fetchAllChangeFeedPages
  -> newCollectionRoutingMap
  -> isCompleteSetOfRanges

newCollectionRoutingMap appends every surviving record to orderedRanges. It separately creates rangeByID, which deduplicates by ID, but does not rebuild orderedRanges from that map. Validation therefore runs against the non-deduplicated slice.

What did you expect or want to happen?

The full-refresh path should produce one current entry per physical range ID before validating continuity, matching the incremental merge behavior.

Alternatively, this condition should be retried internally or returned as a typed retryable error.

How can we reproduce it?

  1. Create a new azcosmos.Client against a partitioned container undergoing physical partition splits.
  2. Call ReadFeedRanges, or start concurrent ReadChangeFeed calls, while the client’s partition-range cache is empty.
  3. Have the full partition-range change feed return multiple revisions of one range ID.
  4. Observe newCollectionRoutingMap retain both revisions in orderedRanges.
  5. Observe isCompleteSetOfRanges report that the range overlaps itself.

Concurrent callers receive the same error because they share the in-flight cache refresh. A later refresh can succeed and populate the cache.

Anything we should know about your environment?

The issue occurs during cold cache initialization. Long-lived clients can recover when a later operation successfully refreshes the cache, while short-lived jobs can fail on each new client initialization.

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.CosmosService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions