Skip to content

Normalize attempt to upgrade consistency level to silently ignore them#49606

Open
FabianMeiswinkel wants to merge 8 commits into
Azure:mainfrom
FabianMeiswinkel:users/fabianm/InvalidConsistencies
Open

Normalize attempt to upgrade consistency level to silently ignore them#49606
FabianMeiswinkel wants to merge 8 commits into
Azure:mainfrom
FabianMeiswinkel:users/fabianm/InvalidConsistencies

Conversation

@FabianMeiswinkel

@FabianMeiswinkel FabianMeiswinkel commented Jun 23, 2026

Copy link
Copy Markdown
Member

Previous behavior

Request-Level Consistency Override Results - Emulator

Mode Endpoint readItem invalid overrides pointQuery invalid overrides
Direct TCP https://localhost:8888/ All silently succeeded: Strong, BoundedStaleness, Session, ConsistentPrefix All silently succeeded: Strong, BoundedStaleness, Session, ConsistentPrefix
RoutingGateway https://localhost:8888/ Strong and BoundedStaleness returned expected 400; Session and ConsistentPrefix silently succeeded All silently succeeded: Strong, BoundedStaleness, Session, ConsistentPrefix
ComputeGateway https://localhost:9999/ All silently succeeded: Strong, BoundedStaleness, Session, ConsistentPrefix All silently succeeded: Strong, BoundedStaleness, Session, ConsistentPrefix

Request-Level Consistency Override Results - Compute Gateway Live account

Mode LatestCommitted read/query Request-level upgrade behavior
GatewayV1-SingleWrite Passed readItem and pointQuery both unexpectedly succeeded for Strong, BoundedStaleness, Session, and ConsistentPrefix; all returned 200/0 with effective consistency matching the requested stronger level.
GatewayV2ThinClient-SingleWrite Passed readItem correctly returned 400/13005 for all four stronger consistencies, but pointQuery still unexpectedly succeeded for all four with 200/0.
DirectTcp-SingleWrite Passed Same as Gateway V1: readItem and pointQuery both unexpectedly succeeded for all four stronger consistencies with 200/0.

Copilot AI review requested due to automatic review settings June 23, 2026 11:32
@FabianMeiswinkel FabianMeiswinkel requested review from a team and kirankumarkolli as code owners June 23, 2026 11:32
@FabianMeiswinkel

Copy link
Copy Markdown
Member Author

/azp run java - 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

This PR updates Cosmos Java client request header handling so that attempts to upgrade consistency (requesting a stricter consistency than the account default) are silently ignored instead of being sent to gateways that may reject the request. It also wires a new live test profile and adds an integration test suite intended to validate the behavior.

Changes:

  • Add a shared Utils.isConsistencyLevelUpgrade helper and use it to suppress/strip unsupported x-ms-consistency-level upgrades.
  • Centralize consistency header application/removal in RxDocumentClientImpl and apply similar filtering in query header creation and client effective-consistency resolution.
  • Add a new -Pconsistency-overrides live test profile (pipeline matrices, Maven profile, TestNG suite, and a new validation test).
Show a summary per file
File Description
sdk/cosmos/live-thinclient-platform-matrix.json Adds -Pconsistency-overrides to thin client live matrix selection/display names.
sdk/cosmos/live-platform-matrix.json Adds -Pconsistency-overrides to the main live test matrix selection/display names.
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Utils.java Introduces isConsistencyLevelUpgrade and a consistency “rank” helper.
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java Applies consistency header only when applicable and removes unsupported upgrade headers before sending.
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/DocumentQueryExecutionContextBase.java Avoids sending a client-level consistency override when it would be an upgrade vs account default.
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncClient.java Ignores operation/client desired consistency settings that would upgrade beyond account default.
sdk/cosmos/azure-cosmos-tests/src/test/resources/consistency-overrides-testng.xml Adds a dedicated TestNG suite for the new consistency override validation group.
sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/TestSuiteBase.java Registers the new consistency-overrides group in suite setup/teardown.
sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosConsistencyOverrideValidationTest.java Adds integration validation for request-level consistency upgrades being ignored (and read-consistency-strategy behavior).
sdk/cosmos/azure-cosmos-tests/pom.xml Adds the consistency-overrides Maven profile to run the new TestNG suite/group.

Copilot's findings

  • Files reviewed: 11/11 changed files
  • Comments generated: 1

@FabianMeiswinkel

Copy link
Copy Markdown
Member Author

/azp run java - cosmos - tests

@azure-pipelines

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

@FabianMeiswinkel

Copy link
Copy Markdown
Member Author

/azp run java - cosmos - tests

@azure-pipelines

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

@FabianMeiswinkel

Copy link
Copy Markdown
Member Author

/azp run java - cosmos - tests

@azure-pipelines

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants