[Gateway V1/V2]: Enable ReadConsistencyStrategy.#48787
Draft
jeet1995 wants to merge 11 commits intoAzure:mainfrom
Draft
[Gateway V1/V2]: Enable ReadConsistencyStrategy.#48787jeet1995 wants to merge 11 commits intoAzure:mainfrom
jeet1995 wants to merge 11 commits intoAzure:mainfrom
Conversation
…n modes (Azure#48094) - Add ReadConsistencyStrategy RNTBD header (0x00F0, String) to RntbdConstants and RntbdRequestHeaders for thin client proxy propagation - Replace Gateway-mode warn+ignore with client-side GLOBAL_STRONG validation that works across all modes (direct, gateway, thin client) - Update ReadConsistencyStrategy javadoc to reflect all-modes support - Add unit tests for RNTBD token encoding and round-trip - Add E2E tests for thin client and compute gateway ReadConsistencyStrategy Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
a3d4c0f to
26648a7
Compare
…is set (Azure#48094) RxGatewayStoreModel.applySessionToken() called RequestHelper.getReadConsistencyStrategyToUse() which had a side-effect of rewriting x-ms-consistency-level header (e.g., LATEST_COMMITTED mapped to BoundedStaleness). The compute gateway rejected this because BoundedStaleness is stricter than the Session account default. Fix: Use a copy of the headers map so the original x-ms-consistency-level is preserved. Gateway/proxy now sees: - x-ms-consistency-level: Session (original, unchanged) - x-ms-cosmos-read-consistency-strategy: LatestCommitted (RCS intent) Verified E2E: LATEST_COMMITTED, EVENTUAL, SESSION, client-level RCS all return 200. GLOBAL_STRONG correctly throws BadRequestException on Session account. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…Azure#48094) Compute gateway rejects requests containing both x-ms-consistency-level and x-ms-cosmos-read-consistency-strategy headers. When RCS is non-DEFAULT, remove the consistency-level header — RCS takes precedence. Applied to both client-level and request-options-level RCS paths in RxDocumentClientImpl.getRequestHeaders(). Verified E2E against test4 compute gateway (swkrish-session, Session account): LATEST_COMMITTED, EVENTUAL, SESSION, client-level RCS all return 200. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…yte (Azure#48094) The proxy expects ReadConsistencyStrategy as a Byte enum, not a String: Eventual=1, Session=2, LatestCommitted=3, GlobalStrong=4 With String type, the proxy couldn't parse the RNTBD frame and hung. With Byte type, thin client reads work correctly through the proxy. Added RntbdReadConsistencyStrategy enum to RntbdConstants matching the proxy's ReadConsistencyStrategy.h enum values. Verified E2E against test4 thin client proxy (swkrish-session): SESSION, EVENTUAL, LATEST_COMMITTED all return 200 with tc=true. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…urations (Azure#48094) Removed hardcoded database/container names. Tests now: - Create a unique database and container in @BeforeClass - Clean up in @afterclass - Use TestConfigurations.HOST/MASTER_KEY from cosmos-v4.properties - Use /pk as partition key path Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…zure#48094) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…t option types (Azure#48094) Cover all 5 surfaces: ItemRequestOptions, QueryRequestOptions, ChangeFeedRequestOptions, ReadManyRequestOptions, CosmosClientBuilder (client-level). Plus write-ignored, GLOBAL_STRONG validation, and CL+RCS precedence tests. Tests use dynamic database/container creation, TestConfigurations, serverless-safe. Follows ThinClientTestBase pattern from PR Azure#47759. Verified E2E: 21/21 PASS (10 thin client + 11 gateway V1) against swkrish-session (test4, Session, North Europe). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Cosmos DB RP now rejects API version 2022-08-15 for accounts with EnableNoSQLVectorSearch capability, requiring 2023-04-15 or later. Error: 'Please use api version 2022-02-15-preview or 2023-04-15 or later' ActivityId: 3e0f30d8-548a-408f-9827-09c3b81a7166 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run java - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Verifying that the API version rejection was caused by EnableNoSQLVectorSearch. This commit will be reverted after pipeline verification. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run java - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
…QLVectorSearch (Azure#48094) Cosmos DB RP now requires API version 2023-04-15+ for accounts with EnableNoSQLVectorSearch capability. Confirmed by testing: - 2022-08-15 + EnableNoSQLVectorSearch = 400 BadRequest - 2022-08-15 without EnableNoSQLVectorSearch = passes - 2023-04-15 + EnableNoSQLVectorSearch = passes Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Issue
Fixes #48094
Summary
Enable
ReadConsistencyStrategyacross all connection modes — Direct (already working), Gateway V1 (compute gateway), and Gateway V2 (thin client proxy). Previously, RCS was only supported in Direct mode; Gateway mode warned and ignored the setting.What changed
RNTBD header encoding — Added
ReadConsistencyStrategyRNTBD token (ID0x00F0, Byte type) so the thin client proxy can read the strategy from the binary request frame. Token values:Eventual=1,Session=2,LatestCommitted=3,GlobalStrong=4. Coordinated with proxy team (ADO PR #2031635).Dual-header conflict resolution — Compute gateway rejects requests containing both
x-ms-consistency-levelandx-ms-cosmos-read-consistency-strategyheaders. When RCS is non-DEFAULT, the SDK now stripsx-ms-consistency-levelso only the RCS header is sent. This applies to both client-level and request-level RCS paths.Gateway store model side-effect fix —
RxGatewayStoreModel.applySessionToken()calledRequestHelper.getReadConsistencyStrategyToUse()which had a side-effect of rewritingx-ms-consistency-level(e.g.,LatestCommitted→BoundedStaleness). The compute gateway then rejected becauseBoundedStalenessis stricter than the Session account default. Fixed by using a copy of the headers map for session token determination.Client-side GLOBAL_STRONG validation — Replaced the Gateway-mode "warn and ignore" with a fail-fast
BadRequestExceptionwhenGLOBAL_STRONGis set on a non-Strong consistency account. Works across all connection modes.Javadoc update —
ReadConsistencyStrategyjavadoc now reflects support in Direct, Gateway, and thin client modes.Key design decisions
ReadConsistencyStrategyas a C++ enum (int). String type caused proxy to hang on frame deserialization.0x00F0HubRegionProcessingOnly(0x00EF). Matches proxy PR #2031635.thinClientHeadersInOrderListx-ms-consistency-levelwhen RCS is setRequestInvokerHandlertest: "ConsistencyLevel header should not be set when ReadConsistencyStrategy is used").RxGatewayStoreModeluses header map copygetReadConsistencyStrategyToUse()side-effect from mutating the original request headers that go on the wire.RequestHelper.validateReadConsistencyStrategy()in Direct mode.Files changed
RntbdConstants.javaRntbdReadConsistencyStrategyenum (Byte values) +ReadConsistencyStrategyheader (0x00F0, Byte)RntbdRequestHeaders.javaRxDocumentClientImpl.javax-ms-consistency-levelwhen RCS is set; replace warn with GLOBAL_STRONG validationRxGatewayStoreModel.javaIDocumentQueryClient.javavalidateAndLogNonDefault...→validateReadConsistencyStrategyChangeFeedQueryImpl.java,DocumentQueryExecutionContextBase.javaReadConsistencyStrategy.javaCHANGELOG.mdRntbdReadConsistencyStrategyHeaderTests.java(new)ThinClientReadConsistencyStrategyE2ETest.java(new)GatewayReadConsistencyStrategyE2ETest.java(new)E2E test coverage
All 5 request option surfaces + client-level + validation:
CosmosItemRequestOptions(LC, Eventual, Session)CosmosQueryRequestOptions(LC, Eventual)CosmosChangeFeedRequestOptions(LC)CosmosReadManyRequestOptions(LC)CosmosClientBuilderclient-level (LC)ConsistencyLevel+ RCS (RCS wins)GLOBAL_STRONGon Session account (rejected)21/21 pass against
swkrish-session(test4, Session, North Europe, serverless, thin-client-enabled federationcdb-ms-test4-northeurope1-fe1)..NET SDK reference
PR #5685 — .NET SDK
ReadConsistencyStrategyimplementation. HTTP header name and enum values match. .NET test confirms: "ConsistencyLevel header should not be set when ReadConsistencyStrategy is used".Proxy coordination
ADO PR #2031635 — "Add ReadConsistencyStrategy for Proxy". Merged and deployed to test4 federations. RNTBD header ID
0x00F0and Byte enum values are aligned.SDK Contribution checklist:
Testing Guidelines