Skip to content

feat: Support conditional upsert in MilvusClient - #3896

Merged
sre-ci-robot merged 1 commit into
milvus-io:masterfrom
weiliu1031:conditional-write-sdk
Nov 26, 2026
Merged

sre-ci-robot merged 1 commit into
milvus-io:masterfrom
weiliu1031:conditional-write-sdk

Conversation

@weiliu1031

@weiliu1031 weiliu1031 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

issue: milvus-io/milvus#54532

Add write_condition and written-row succ_index support to synchronous and asynchronous MilvusClient.upsert.

Behavior

  • Accept GT/GTE integer-version conditions and insert/skip/error policies for missing rows.
  • Conditions automatically imply partial_update.
  • Raise DataNotMatchException when the condition field is absent from the cached schema so existing schema-refresh retry can recover.
  • Preserve upstream PATH_REPLACE and field_ops packing: GT permits operations on non-version fields; GTE requires REPLACE operations; the version field itself requires REPLACE.
  • Return original request indexes (succ_index) aligned with written ids when write_condition is supplied; omitted/skipped rows do not appear. Ordinary upsert response shapes remain unchanged.
  • Keep existing SDK retry and connection-recovery behavior unchanged (cross-RPC idempotency is not handled in this PR).

Upstream alignment

Rebased onto PyMilvus master ff967fd4f6ec4c10215bc966c396438b75935d59. The inherited proto submodule already contains the merged conditional-write protocol, so this PR carries no separate proto pin or generated-file diff.

Server implementation: merged Milvus PR #54697.
Design: Conditional upsert.

Upgrade every serving Proxy before enabling conditional traffic. Old Proxies can silently ignore the field and perform unconditional writes.

Validation

  • Targeted unit suite on ff967fd4: 404 passed (prepare, grpc_handler, async_grpc_handler, MilvusClient, AsyncMilvusClient).
  • Ruff, Black, and git diff --check passed.

@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.90%. Comparing base (ff967fd) to head (fd09f67).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3896   +/-   ##
=======================================
  Coverage   94.89%   94.90%           
=======================================
  Files          81       81           
  Lines       17784    17809   +25     
=======================================
+ Hits        16877    16902   +25     
  Misses        907      907           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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 Oct 26, 2026
@weiliu1031
weiliu1031 force-pushed the conditional-write-sdk branch from 4f7e51b to aac2451 Compare November 17, 2026 03:12
@weiliu1031
weiliu1031 marked this pull request as ready for review November 17, 2026 03:12
@mergify mergify Bot removed the ci-passed label Nov 17, 2026
@mergify

mergify Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

This pull request is merged.

@mergify mergify Bot added the ci-passed label Nov 17, 2026
@weiliu1031
weiliu1031 force-pushed the conditional-write-sdk branch from aac2451 to b9404d5 Compare November 26, 2026 02:44
@weiliu1031 weiliu1031 changed the title feat: Support conditional upsert without unsafe RPC replay feat: Support conditional upsert in MilvusClient Nov 26, 2026
@mergify mergify Bot added ci-passed and removed ci-passed labels Nov 26, 2026
issue: milvus-io/milvus#54532

Add write_condition and written-row succ_index support to synchronous
and asynchronous MilvusClient upserts:
- Validate and pack GT/GTE integer-version conditions with
  insert/skip/error missing-row policies in Prepare.row_upsert_param.
- Auto-promote partial_update when write_condition is set; reject
  incompatible field_ops (non-REPLACE on the version field, or any
  non-REPLACE op with GTE).
- Raise DataNotMatchException when the condition field is missing from
  the cached schema so existing schema-refresh retry can recover.
- Return succ_index aligned with written IDs only when write_condition
  is supplied; leave ordinary upsert responses unchanged.

Validation:
- uv run --frozen --group dev pytest tests/unit/prepare/test_partial_op.py tests/unit/grpc_handler/test_data.py tests/unit/async_grpc_handler/test_async_data.py tests/unit/test_milvus_client.py tests/unit/test_async_milvus_client_reuse.py -q
- Ruff, Black, and git diff --check passed.

Signed-off-by: Wei Liu <wei.liu@zilliz.com>

@XuanYang-cn XuanYang-cn 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.

/lgtm

@sre-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: weiliu1031, XuanYang-cn

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

@sre-ci-robot
sre-ci-robot merged commit c4238ce into milvus-io:master Nov 26, 2026
14 checks passed
@pymilvus-bot

Copy link
Copy Markdown
Collaborator

✅ Backport Created
Hi @weiliu1031, Backport PR for 3.0 has been created: #3952

(cc @XuanYang-cn)

pymilvus-bot added a commit to pymilvus-bot/pymilvus that referenced this pull request Nov 26, 2026
Pin milvus-proto to milvus-io/milvus-proto#685 and regenerate the
Python bindings. This gives the synchronous and asynchronous upsert
paths in milvus-io#3896 the WriteCondition message they serialize.

pr: milvus-io#3952
See also: milvus-io/milvus#54532

Signed-off-by: pymilvus-bot <pymilvus@zilliz.com>
sre-ci-robot pushed a commit that referenced this pull request Nov 26, 2026
… (#3952)

Backport of #3896 to `3.0`.

---------

Signed-off-by: Wei Liu <wei.liu@zilliz.com>
Signed-off-by: pymilvus-bot <pymilvus-bot@users.noreply.github.com>
Signed-off-by: pymilvus-bot <pymilvus@zilliz.com>
Co-authored-by: wei liu <wei.liu@zilliz.com>
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.

4 participants