Skip to content

fix(migrate): forward batch_size to the upload calls - #1459

Open
feiiiiii5 wants to merge 1 commit into
qdrant:devfrom
feiiiiii5:fix/migrate-upload-batch-size
Open

feiiiiii5 wants to merge 1 commit into
qdrant:devfrom
feiiiiii5:fix/migrate-upload-batch-size

Conversation

@feiiiiii5

Copy link
Copy Markdown
Contributor

Problem

migrate() documents batch_size as covering both reading and writing, but only scrolling ever saw it — every upload was sized by upload_points' own default of 64:

  • qdrant_client/migrate/migrate.py:171batch_size (int, optional): Batch size for scrolling and uploading vectors. Defaults to 100.
  • QdrantClient.migrate (qdrant_client/qdrant_client.py:2508) — scroll and upsert operations.

So client.migrate(dest, batch_size=1000) still sends 64 points per request. For a large collection that is the difference between a usable migration and hours of round trips, and the documented knob simply does nothing.

Cause

_migrate_collection() passes batch_size to source_client.scroll(...) but calls upload_with_retry(...) without it, and upload_with_retry() never forwarded a batch_size to client.upload_points() at all.

Change

Thread the value through: upload_with_retry() gains a trailing batch_size: int = 64 parameter (matching upload_points' default) and passes it to upload_points(); both call sites in _migrate_collection() forward the caller's value. The parameter is appended to a module-private helper, so existing calls stay compatible, and no public signature changed.

Testing

New test in tests/test_migrate.py spies on upload_points and asserts every write received the requested size:

(cd repo root) python -m pytest tests/test_migrate.py::test_migrate_forwards_batch_size_to_upload -q
  • pristine 589a87a (test file added, source untouched): 1 failed — the spy recorded forwarded [None], i.e. the batch size never arrived.
  • this branch: 1 passed.

Full file at head: python -m pytest tests/test_migrate.py -q16 failed, 10 passed, 2 errors; the same command on pristine 589a87a gives 16 failed, 9 passed, 2 errors. Those 16+2 are the pre-existing cases that need a live server (qdrant_client.http.exceptions ... connection refused) and fail identically before and after — the only delta is my new passing test. The new test itself runs fully offline against two QdrantClient(":memory:") instances.

ruff check passes on both changed files. ruff format --check --line-length=99 reports tests/test_migrate.py would be reformatted at base and at head with the identical 4-line deviation (the strict_mode_config block in test_recreate_collection), so I left that pre-existing drift alone instead of mixing a reformat into this diff — qdrant_client/migrate/migrate.py is format-clean.

Notes for the reviewer

migrate() and QdrantClient.migrate() both document batch_size as the batch size
for scroll and upsert operations, but _migrate_collection never passed it to
upload_with_retry, so every write request was sized by upload_points' own
default of 64 no matter what the caller asked for. Thread the value through.
@netlify

netlify Bot commented Sep 20, 2026

Copy link
Copy Markdown

Deploy Preview for poetic-froyo-8baba7 ready!

Name Link
🔨 Latest commit 80defec
🔍 Latest deploy log https://app.netlify.com/projects/poetic-froyo-8baba7/deploys/6aafc0fc4e62a90008f9f6e3
😎 Deploy Preview https://deploy-preview-1459--poetic-froyo-8baba7.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Sep 20, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 8dc30201-4ba1-4ab9-9689-f0df0e14eb9b

📥 Commits

Reviewing files that changed from the base of the PR and between 589a87a and 80defec.

📒 Files selected for processing (2)
  • qdrant_client/migrate/migrate.py
  • tests/test_migrate.py

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

upload_with_retry now accepts a configurable batch_size and forwards it to upload_points. _migrate_collection passes its configured batch size to initial and subsequent uploads. A new test verifies that migrate(batch_size=25) uses that value for every upload and transfers all points.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Issue #1217 requires _migrate_collection() to use limit=batch_size on the first source_client.scroll() call and requires a test that verifies this call. At the reviewed head, migrate.py still … Change the first scroll call to limit=batch_size. Add an offline test that verifies the first scroll request uses the configured batch size, such as limit=3.
Out of Scope Changes check ⚠️ Warning The pull request changes upload_with_retry() and both upload paths to forward batch_size, and adds an upload forwarding test. Issue #1217 covers the first scroll page and its scroll-limit test. Th… Remove the upload forwarding implementation and its test from this pull request, or link the upload objective to a separate issue and submit it separately.
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: forwarding the caller-provided batch_size to migration upload calls.
Description check ✅ Passed The description is directly related to the changeset. It explains the problem, cause, implementation, compatibility, testing, and scope.
Full details: Linked Issues check

Explanation

Issue #1217 requires _migrate_collection() to use limit=batch_size on the first source_client.scroll() call and requires a test that verifies this call. At the reviewed head, migrate.py still uses limit=2 for the first scroll. The added test verifies upload batch_size, not the first scroll limit.

Full details: Out of Scope Changes check

Explanation

The pull request changes upload_with_retry() and both upload paths to forward batch_size, and adds an upload forwarding test. Issue #1217 covers the first scroll page and its scroll-limit test. The upload changes do not implement that objective and the PR summary identifies them as separate work.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant