Skip to content

fix(local): publish DBM migrations only after successful conversion - #1442

Open
Kuang-xianxin wants to merge 1 commit into
qdrant:devfrom
Kuang-xianxin:fix/retryable-dbm-migration
Open

Kuang-xianxin wants to merge 1 commit into
qdrant:devfrom
Kuang-xianxin:fix/retryable-dbm-migration

Conversation

@Kuang-xianxin

Copy link
Copy Markdown

If DBM-to-SQLite migration fails after opening the destination, it leaves storage.sqlite behind. The next collection open treats that file as a completed migration and silently skips the points still in storage.dbm.

Build the SQLite database in a temporary directory beside the destination, commit and close both stores, then publish the completed file with Path.replace. The legacy store is opened read-only and removed only after publication. Exceptions close the handles and remove the staging files, allowing a later open to retry.

The regression uses real DBM and SQLite files: a malformed legacy key aborts migration; after repairing that key, opening the store again recovers every valid point. It fails on the unmodified dev implementation. This addresses the recovery limitation noted in #1335; its separate logging-format change remains outside this PR.

Validation on Windows / Python 3.13.14: the regression and 10 other applicable persistence/in-memory tests pass. The two complete files report 11 passed and 4 failures; the same four failures reproduce on unmodified da05a2b (existing Windows collection-deletion/open-handle behavior). Scoped Ruff lint/format, source Mypy, and git diff --check pass. No server-backed integration suite was run.

All Submissions

Changes to Core Features

  • Explained the failure and the fix.
  • Added a regression test.
  • Ran relevant local tests; existing failures are described above.

@netlify

netlify Bot commented Sep 16, 2026

Copy link
Copy Markdown

Deploy Preview for poetic-froyo-8baba7 ready!

Name Link
🔨 Latest commit 20ff5c4
🔍 Latest deploy log https://app.netlify.com/projects/poetic-froyo-8baba7/deploys/6aaa1399c7f5650008a90a3c
😎 Deploy Preview https://deploy-preview-1442--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 16, 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: a5e29106-4d5a-4900-a481-8e0212c9674e

📥 Commits

Reviewing files that changed from the base of the PR and between da05a2b and 20ff5c4.

📒 Files selected for processing (2)
  • qdrant_client/local/persistence.py
  • tests/test_local_persistence.py

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


📝 Walkthrough

Walkthrough

The migration now writes SQLite data in a temporary directory and publishes the completed database by replacement. It opens the legacy DBM store in read-only mode and closes resources through context managers. Failed migrations leave the legacy store available for retry and do not create a partial destination. A new test covers failure, retry, point loading, and legacy-file cleanup.

Area Change
Migration Added staged SQLite creation and atomic publication.
Tests Added coverage for failed and retried migrations.
Suggested reviewers: joein

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 20ff5

The migration preserves the legacy store until a completed SQLite database is published, and failed conversions can be retried without exposing a partial destination.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the DBM-to-SQLite migration failure, the staging and publication fix, the regression test, and validation results.
Title check ✅ Passed The title clearly and concisely summarizes the main change: publishing DBM migrations only after successful conversion.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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