Skip to content

fix - full partition key routing bug#48237

Open
dibahlfi wants to merge 3 commits into
mainfrom
users/dibahl/full-partitionkey-regression
Open

fix - full partition key routing bug#48237
dibahlfi wants to merge 3 commits into
mainfrom
users/dibahl/full-partitionkey-regression

Conversation

@dibahlfi

Copy link
Copy Markdown
Member

Bug: Single-partition queries that pass a complete  partition_key  stopped using partition-key routing and instead scanned the whole logical partition.

For a query like  SELECT VALUE COUNT(1)  with  partition_key="PowerCut" , the SDK dropped the  x-ms-documentdb-partitionkey  header and instead sent an effective-partition-key (EPK) hash range via  x-ms-documentdb-partitionkeyrangeid  +  x-ms-start-epk / x-ms-end-epk . That request shape loses the server-side index-only aggregate, so the service reads every document in the partition and returns them page by page.

See below issue for more details:
#48209

Copilot AI review requested due to automatic review settings July 24, 2026 04:50
@dibahlfi
dibahlfi requested a review from a team as a code owner July 24, 2026 04:50
@dibahlfi

Copy link
Copy Markdown
Member Author

/azp run python - cosmos - tests

@dibahlfi

Copy link
Copy Markdown
Member Author

@sdkReviewAgent-2

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
8 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Restores partition-key routing for complete keys to prevent costly aggregate scans.

Changes:

  • Routes complete keys through standard partition-key headers; retains EPK routing for HPK prefixes.
  • Simplifies continuation-token handling.
  • Adds sync/async regression, pagination, and routing tests.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
CHANGELOG.md Documents the routing fix.
container.py Stops forwarding unnecessary container properties.
_cosmos_client_connection.py Restores sync partition-key routing.
aio/_cosmos_client_connection_async.py Adjusts async routing and continuation handling.
_routing/feed_range_continuation.py Simplifies legacy-token policy.
test_query.py Tests sync index-only COUNT.
test_query_async.py Tests async index-only COUNT.
test_query_feed_range_multipartition.py Tests sync continuation compatibility.
test_query_feed_range_multipartition_async.py Tests async continuation compatibility.
test_partition_split_retry_unit.py Verifies sync routing headers.
test_partition_split_retry_unit_async.py Verifies async routing headers.
test_feed_range_continuation_token.py Updates token-policy tests.

Comment thread sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py
@xinlian12

Copy link
Copy Markdown
Member

Review complete (26:59)

Posted 3 inline comment(s).

Steps: ✓ context, correctness, cross-sdk, design, history, past-prs, synthesis, test-coverage

Copilot AI review requested due to automatic review settings July 24, 2026 16:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Note

This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.

@dibahlfi

Copy link
Copy Markdown
Member Author

/azp run python - cosmos - tests

@dibahlfi

Copy link
Copy Markdown
Member Author

@sdkReviewAgent-2

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@github-actions

Copy link
Copy Markdown
Contributor
[Pilot] PR Pipeline Failure Analysis

A CI pipeline failed on this pull request. Here is an automated analysis of what went wrong and how to get the build green.

What failed

The Use Python version task failed in the pipeline with an HTTP 504 (Gateway Timeout) error while trying to download Python 3.11 x64 from the GitHub Actions python registry. The macOS agent only has arm64 builds of Python cached (3.11.9 arm64, 3.12.10 arm64, etc.) and could not fall back to an x64 build after the download failed.

Build: https://dev.azure.com/azure-sdk/public/_build/results?buildId=6613916

Recommended next steps

  • Re-run the pipeline — this is a transient infrastructure failure (network 504 from the GitHub python registry), not a code issue. Re-triggering the build is the recommended first step.
  • If the failure recurs, check the Azure DevOps hosted agent software list to confirm Python 3.11 x64 availability on the macOS image in use.
  • See the CI troubleshooting guide: https://aka.ms/ci-fix
  • Push new commits to address the failures; this comment updates automatically on the next failing run.
Raw pipeline analysis (azsdk ci analyze)
Analyzing pipeline https://github.com/Azure/azure-sdk-for-python/pull/48237...
--------------------------------------------------------------------------------
Failed Tasks
--------------------------------------------------------------------------------
### Errors:
--> /tmp/log-analysis-ba341269f4bf480799aeb07e0ee132d8.txt:147
2026-07-24T16:18:29.2706070Z ==============================================================================
Task         : Use Python version
Description  : Use the specified version of Python from the tool cache, optionally adding it to the PATH
==============================================================================
2026-07-24T16:18:29.5710230Z Downloading: https://github.com/actions/python-versions/releases/download/3.11.9-9947079978/python-3.11.9-darwin-x64.tar.gz
##[error]Failed to download Python from the Github Actions python registry (https://github.com/actions/python-versions). Error: Error: Unexpected HTTP response: 504
##[error]Version spec 3.11 for architecture x64 did not match any version in Agent.ToolsDirectory.
Versions in /Users/runner/hostedtoolcache:
  3.11.9 (arm64)
  3.12.10 (arm64)
  3.13.14 (arm64)
  3.14.6 (arm64)

### Pipeline: https://dev.azure.com/azure-sdk/public/_build/results?buildId=6613916

Copilot detected the failing pipeline and generated the analysis above. To have it attempt a fix automatically, reply with @copilot please fix the failing pipeline on this PR.

Generated by Pipeline Analysis - Next Steps · 18.8 AIC · ⌖ 6.16 AIC · ⊞ 6.7K ·

Comment thread sdk/cosmos/azure-cosmos/CHANGELOG.md
Comment thread sdk/cosmos/azure-cosmos/tests/test_query_async.py
Comment thread sdk/cosmos/azure-cosmos/tests/test_query.py
@xinlian12

Copy link
Copy Markdown
Member

Review complete (50:29)

Posted 3 inline comment(s).

Steps: ✓ context, correctness, cross-sdk, design, history, past-prs, synthesis, test-coverage

Copilot AI review requested due to automatic review settings July 24, 2026 17:40
@dibahlfi

Copy link
Copy Markdown
Member Author

/azp run python - cosmos - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

@tvaron3 tvaron3 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

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.

4 participants