Integrate Stored Procedure and Query Plan request routing to Gateway V2 endpoint#47759
Open
jeet1995 wants to merge 90 commits into
Open
Integrate Stored Procedure and Query Plan request routing to Gateway V2 endpoint#47759jeet1995 wants to merge 90 commits into
jeet1995 wants to merge 90 commits into
Conversation
Member
Author
|
/azp run java - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Member
Author
|
/azp run java - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Member
Author
|
/azp run java - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
xinlian12
reviewed
Jan 30, 2026
xinlian12
reviewed
Jan 30, 2026
xinlian12
reviewed
Jan 30, 2026
xinlian12
reviewed
Jan 30, 2026
xinlian12
reviewed
Jan 30, 2026
mbhaskar
reviewed
Jan 30, 2026
mbhaskar
reviewed
Jan 30, 2026
…readiness probe for thin-client-default-on - Remove the QueryPlan exemption in assertThinClientEndpointUsed: when ThinClient is opted in with HTTP/2 enabled, QueryPlan calls MUST also route to Gateway V2 (:10250), matching production default DEFAULT_THINCLIENT_QUERY_PLAN_ENABLED=true. - Restore public static visibility on ThinClientTestBase.assertThinClientEndpointUsed / assertGatewayEndpointUsed so cross-package static imports (CosmosMultiHashTest) compile. - Add OWNER_RESOURCE_NOT_EXISTS (subStatus 1003) to the retryable NOTFOUND allowlist in TestSuiteBase.isRetryableCollectionReadinessFailure. With thin-client default-on the beforeSuite readability probe (a QueryPlan) routes through GW V2; a freshly-created container not yet propagated to a secondary region returns 404/1003, which must be treated as a transient readiness failure instead of cascade-skipping the suite. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run java - cosmos - tests |
Member
Author
|
/azp run java - cosmos - spark |
Member
Author
|
/azp run java - cosmos - kafka |
|
Azure Pipelines successfully started running 1 pipeline(s). |
2 similar comments
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Validate the COSMOS.THINCLIENT_QUERY_PLAN_ENABLED sysprop/env kill-switch in both directions: - Unit: new case in ReadManyByPartitionKeyQueryPlanRoutingTest asserts QueryPlan is forced to Gateway V1 (useGatewayMode=true) when the flag is disabled, even with thin-client eligible. - E2E: make TestSuiteBase.assertThinClientEndpointUsed flag-aware so QueryPlan endpoint assertions flip based on the live-read flag while data operations continue to route to the thin-client endpoint. Both scenarios verified green (unit 3/3; E2E 112/112, oracle:true for flag ON and flag OFF). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run java - cosmos - tests |
Member
Author
|
/azp run java - cosmos - kafka |
Member
Author
|
/azp run java - cosmos - spark |
|
Azure Pipelines successfully started running 1 pipeline(s). |
2 similar comments
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Member
Author
|
/azp run java - cosmos - tests |
Member
Author
|
/azp run java - cosmos - spark |
Member
Author
|
/azp run java - cosmos - kafka |
|
Azure Pipelines successfully started running 1 pipeline(s). |
2 similar comments
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Azure Pipelines successfully started running 1 pipeline(s). |
jeet1995
added a commit
to jeet1995/azure-sdk-for-java
that referenced
this pull request
Jul 8, 2026
…zure#47759 merge The Azure#47759 merge conflict resolution kept HEAD's short-circuit-wait loop (which calls isAnyRegionShortCircuitedForPartition) but dropped the method definition. Recovered from probe tip 42c2c7d and re-inserted. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
ThinClientTestBase teardown unconditionally cleared the COSMOS.THINCLIENT_ENABLED system property. Since Configs.isThinClientEnabled() reads the property lazily per client build, a ThinClientTestBase subclass running before a property-dependent class inherited from main (e.g. CosmosMultiHashTest, ThinClientQueryE2ETest) in the same JVM wiped the ambient -DCOSMOS.THINCLIENT_ENABLED=true flag supplied by the thin-client CI lane. Later clients then built with thin client disabled and routed to :443, breaking the :10250 thin-client endpoint assertions. Save the prior value on enable and restore it on teardown (clear only when it was originally absent), mirroring CosmosConsistencyOverrideValidationTest's restoreSystemProperty pattern. Helpers changed from static to instance so the saved value is per-instance, avoiding races across TestNG factory instances. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…stBase; revert workflow tests to main
ThinClientTestBase no longer sets/clears COSMOS.THINCLIENT_ENABLED per class. The 'thinclient' Maven lane already sets THINCLIENT_ENABLED=true and HTTP2_ENABLED=true JVM-wide via failsafe systemPropertyVariables, and all thin classes run only in that lane (groups={thinclient}). The prior per-class clearProperty in @afterclass wiped the ambient -D for later byte-identical-to-main classes in the same JVM, mis-routing requests to :443. Relying on the lane flag (matching ThinClientQueryE2ETest) removes that footgun.
Also revert CustomerWorkflowHighE2ETimeoutTest and CustomerWorkflowPartitionLevelCircuitBreakerTest to upstream/main (availability-strategy threshold stays 100ms), since this PR requires no changes there.
Verified locally (AZURE_TEST_MODE=LIVE, -Pthinclient,query,consistency-overrides): 234 passed, 0 failures/skips; QueryPlan routes to :10250.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run java - cosmos - tests |
Member
Author
|
/azp run java - cosmos - spark |
Member
Author
|
/azp run java - cosmos - kafka |
|
Azure Pipelines successfully started running 1 pipeline(s). |
2 similar comments
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Summary
This PR integrates Query Plan and Stored Procedure request routing into the Gateway V2 thin-client (proxy) path, adds the RNTBD protocol surface the proxy needs to generate a query plan, and deserializes the proxy-generated query plan back into the client query pipeline. It also fixes a thin-client query-plan error-status regression and a hybrid/full-text diagnostics gap, and ships an oracle-style E2E suite that validates thin-client parity against Direct TCP.
Production changes (
azure-cosmos)RNTBD protocol surface (Gateway V2 proxy)
RntbdConstants.java— newQueryPlanoperation type (0x0042) and two new request headers:SupportedQueryFeatures(0x00FF,String) andQueryVersion(0x0100,SmallString). IDs match the server-side proxy.RntbdRequestHeaders.java— populate theSupportedQueryFeaturesandQueryVersionRNTBD tokens from their HTTP-header equivalents so the proxy can extract them from the RNTBD body.RntbdRequestFrame.java— wire the newQueryPlanoperation type onto the request frame.Query-plan routing & deserialization
QueryPlanRetriever.java— advertiseCountIfinSUPPORTED_QUERY_FEATURES; routegetQueryPlanThroughGatewayAsyncthrough thin-client mode and pass thepartitionKeyDefinition; defense-in-depth guard that converts a non-2xx / malformed query-plan response into a clean400instead of a leaked exception.PartitionedQueryExecutionInfo.java— thin-client deserialization overload that accepts the partition-key definition (and response timeline), used to construct the query pipeline from a proxy-generated query plan.QueryInfo.java—getGroupByAliasToAggregateType()andCountIfhandling.DocumentQueryExecutionContextFactory.java,IDocumentQueryClient.java— thread the partition-key definition into query-plan retrieval.Stored-procedure routing
RxDocumentClientImpl.java,RxDocumentServiceRequest.java,ThinClientStoreModel.java— route stored-procedure execution through the Gateway V2 thin-client path.Bug fix — thin-client query-plan error status (
statusCode 0→400)RxGatewayStoreModel.validateOrThrow— a thin-client query-plan error frame (non-JSON, NUL-padded body) causednew CosmosError(body)to throw, which escaped before the intendedthrow dceand surfaced upstream asstatusCode 0. It now falls back to a sanitizedCosmosError, so the existing throw carries the real 400 with the server-provided substatus and message preserved. Strictly additive:2xxresponses and valid-JSON error bodies are byte-identical to before — only a previously-leaked exception path is corrected.Diagnostics fix — hybrid / full-text
HybridSearchDocumentQueryExecutionContext.java— propagate the component-query client-side request statistics into the synthetic finalFeedResponse, so endpoint diagnostics still show the core response path forRRF(...)/ full-text queries.Partition-key range routing
PartitionKeyInternalHelper.java— convertPartitionKeyInternalranges into sorted EPK ranges for multi-range routing.Test changes (
azure-cosmos-tests)The monolithic
ThinClientE2ETestis replaced (−378) by a focused thin-client E2E suite (TestNG groupthinclient, proxy:10250):ThinClientQueryE2ETestThinClientChangeFeedE2ETestforFullRange(),forLogicalPartition(), incremental change feedThinClientPointOperationE2ETestThinClientStoredProcedureE2ETestPartitionKey.NONEPartitionKeyInternalTestPartitionKeyInternalranges to sorted EPK rangesQueryPlanRetrieverSupportedFeaturesTestReadManyByPartitionKeyQueryPlanRoutingTestreadManyquery-plan routingGatewayReadConsistencyStrategySpyWireTestPlus:
ThinClientTestBase/TestSuiteBasethin-client helpers,pom.xmlthinclientprofile wiring, andTHINCLIENT_TEST_MATRIX.mdcoverage matrix.Query-test methodology
ThinClientQueryE2ETestruns each query shape against the same seeded data through two paths:Assertions: (1) thin-client diagnostics include a request to the
:10250proxy endpoint, (2) Direct and thin-client result counts match, (3) result contents match — preserving order forORDER BYqueries and compared as sorted sets otherwise.Assertion hardening (F1–F5)
400+ unconditional:10250endpoint assertion on invalid query (locks thestatusCode 0→400fix above; no longer tolerates0).ORDER BY).1e-6numeric tolerance for scalar andGROUP BYaggregates (avoidsSUM/AVGfloat-formatting false mismatches).Query coverage validated
ORDER BY,DISTINCT,TOP,OFFSET/LIMITGROUP BYJOIN,EXISTS,LIKE,BETWEENRRF(...)queriesAll SDK Contribution checklist:
Testing Guidelines