Skip to content

Refine clusterId for MilvusClientV2Session - #2011

Merged
sre-ci-robot merged 1 commit into
milvus-io:masterfrom
yhmo:ma
Aug 13, 2026
Merged

Refine clusterId for MilvusClientV2Session#2011
sre-ci-robot merged 1 commit into
milvus-io:masterfrom
yhmo:ma

Conversation

@yhmo

@yhmo yhmo commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI lite review requested due to automatic review settings August 13, 2026 08:15
@sre-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: yhmo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mergify

mergify Bot commented Aug 13, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Copilot AI left a comment

Copy link
Copy Markdown

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 refines how clusterId is applied when using MilvusClientV2Session, shifting cluster routing from mutating request objects to passing the session’s clusterId through dedicated overloads and marking request-level clusterId as deprecated.

Changes:

  • Update MilvusClientV2Session to pass clusterId to MilvusClientV2/VectorService without mutating SearchReq/QueryReq/HybridSearchReq/GetReq.
  • Add VectorService and MilvusClientV2 overloads that accept an explicit clusterId and inject it into gRPC params.
  • Deprecate request-level clusterId fields and adjust unit tests to assert requests are not mutated by sessions.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
sdk-core/src/test/java/io/milvus/v2/service/vector/VectorTest.java Updates session routing tests to expect no request mutation and session precedence.
sdk-core/src/main/java/io/milvus/v2/service/vector/VectorService.java Adds overloads that accept a clusterId and inject it into outgoing gRPC requests.
sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchReq.java Deprecates request-level clusterId API.
sdk-core/src/main/java/io/milvus/v2/service/vector/request/QueryReq.java Deprecates request-level clusterId API.
sdk-core/src/main/java/io/milvus/v2/service/vector/request/HybridSearchReq.java Deprecates request-level clusterId API.
sdk-core/src/main/java/io/milvus/v2/service/vector/request/GetReq.java Deprecates request-level clusterId API.
sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2Session.java Routes clusterId via overloads rather than mutating request objects for core vector APIs.
sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2.java Adds package-private overloads used by sessions to pass explicit clusterId.
Suppressed comments (2)

sdk-core/src/main/java/io/milvus/v2/service/vector/VectorService.java:268

  • vectorUtils.ConvertToGrpcSearchRequest(request) already adds CLUSTER_ID to searchParams when request.getClusterId() is set (VectorUtils.ConvertToGrpcSearchRequest). This block appends another CLUSTER_ID, which can leave two entries and make the effective cluster routing ambiguous (and breaks the intended “session overrides request” behavior if the server reads the first value).
        if (StringUtils.isNotEmpty(clusterId)) {
            searchRequest = searchRequest.toBuilder()
                    .addSearchParams(KeyValuePair.newBuilder()
                            .setKey(Constant.CLUSTER_ID)
                            .setValue(clusterId)

sdk-core/src/main/java/io/milvus/v2/service/vector/VectorService.java:304

  • vectorUtils.ConvertToGrpcHybridSearchRequest(request) already includes CLUSTER_ID in rankParams when request.getClusterId() is set (via props -> AssembleKvPair). This block appends another CLUSTER_ID, which can produce duplicate/conflicting routing params and make precedence unclear.
        if (StringUtils.isNotEmpty(clusterId)) {
            searchRequest = searchRequest.toBuilder()
                    .addRankParams(KeyValuePair.newBuilder()
                            .setKey(Constant.CLUSTER_ID)
                            .setValue(clusterId)

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread sdk-core/src/main/java/io/milvus/v2/utils/VectorUtils.java
Comment thread sdk-core/src/main/java/io/milvus/v2/utils/VectorUtils.java
Signed-off-by: yhmo <yihua.mo@zilliz.com>
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.05263% with 3 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@82cfb07). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...ava/io/milvus/v2/service/vector/VectorService.java 91.17% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2011   +/-   ##
=========================================
  Coverage          ?   65.12%           
  Complexity        ?     4283           
=========================================
  Files             ?      473           
  Lines             ?    26484           
  Branches          ?     2512           
=========================================
  Hits              ?    17249           
  Misses            ?     7893           
  Partials          ?     1342           
Files with missing lines Coverage Δ
...ain/java/io/milvus/orm/iterator/QueryIterator.java 97.34% <100.00%> (ø)
...in/java/io/milvus/orm/iterator/SearchIterator.java 76.07% <100.00%> (ø)
.../java/io/milvus/orm/iterator/SearchIteratorV2.java 83.45% <100.00%> (ø)
.../main/java/io/milvus/v2/client/MilvusClientV2.java 53.84% <100.00%> (ø)
...ava/io/milvus/v2/client/MilvusClientV2Session.java 100.00% <100.00%> (ø)
...va/io/milvus/v2/service/vector/request/GetReq.java 72.72% <ø> (ø)
...vus/v2/service/vector/request/HybridSearchReq.java 67.56% <ø> (ø)
...us/v2/service/vector/request/QueryIteratorReq.java 75.25% <ø> (ø)
.../io/milvus/v2/service/vector/request/QueryReq.java 78.64% <ø> (ø)
...s/v2/service/vector/request/SearchIteratorReq.java 68.00% <ø> (ø)
... and 4 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mergify mergify Bot added the ci-passed label Aug 13, 2026
@yhmo yhmo added the lgtm label Aug 13, 2026
@sre-ci-robot
sre-ci-robot merged commit f9a30cc into milvus-io:master Aug 13, 2026
8 checks passed
@yhmo
yhmo deleted the ma branch August 13, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants