Skip to content

Keep repeated Milvus registrations idempotent - #1759

Merged
serengil merged 1 commit into
serengil:masterfrom
Afloat16:fix/milvus-registration-idempotence-20261116
Nov 16, 2026
Merged

serengil merged 1 commit into
serengil:masterfrom
Afloat16:fix/milvus-registration-idempotence-20261116

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Tickets

N/A

What has been done

Milvus insert accepts an existing primary key as another entity. Registering the same faces repeatedly therefore adds duplicate entities despite their stable content-derived IDs. Repeating two faces four times leaves eight entities in the native database.

Keep the last record for each ID within a batch and use upsert for the write. Re-registering a face then replaces its existing entity and image name. The returned count continues to count the supplied embeddings, including updates.

How to test

pip install pymilvus==2.6.9 milvus-lite==2.5.1 'setuptools<81'
DEEPFACE_BACKEND_ENGINE=onnx python -m pytest -q \
  tests/integration/test_milvus_registration_lite.py \
  tests/unit/test_milvus_stable_ids.py \
  tests/unit/test_milvus_distance.py \
  tests/unit/test_milvus_complete_gallery.py \
  tests/integration/test_milvus_distance_lite.py \
  tests/integration/test_milvus_complete_gallery_lite.py

Python 3.10 and 3.12 validation, using real PyMilvus 2.6.9 and Milvus Lite 2.5.1:

  • The base revision fails five native registration regressions and passes two controls.
  • The fix passes all 41 tests on each Python version, with no skips. Repeated calls and duplicates within batches leave one entity per stable ID, retain the latest image name, and preserve distinct embeddings.
  • Existing checks cover IDs across interpreter processes, exact/ANN distance agreement, and complete retrieval of a 16,385-record gallery.
  • Pylint: 10.00/10; mypy: 145 source files pass; changed tests pass Black with line length 100.

The database tests use synthetic face arrays and embeddings; no recognition model weights are needed. Milvus documents the insert/upsert distinction here.

@serengil
serengil merged commit a298af0 into serengil:master Nov 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants