Skip to content

fix(qdrant): do not remove local path on init (#4473)#4475

Merged
kartik-mem0 merged 3 commits intomem0ai:mainfrom
Himanshu-Sangshetti:fix/qdrant-local-persist-4473
Mar 23, 2026
Merged

fix(qdrant): do not remove local path on init (#4473)#4475
kartik-mem0 merged 3 commits intomem0ai:mainfrom
Himanshu-Sangshetti:fix/qdrant-local-persist-4473

Conversation

@Himanshu-Sangshetti
Copy link
Copy Markdown
Contributor

Description

Local Qdrant uses a filesystem path for embedded storage. Previously, when on_disk was false (the default in config), Qdrant.__init__ called shutil.rmtree(path) if that directory already existed.:

on_disk in Qdrant refers to VectorParams.on_disk (how vectors are stored inside a collection), not “delete the whole database directory.” Tying “wipe folder” to on_disk=false caused data loss across process restarts (reported in #4473).

This PR removes that rmtree behavior. The local path is opened/reused like a normal database directory; create_col already skips creating a collection if it already exists.

Dependencies

No new runtime dependencies.

Fixes #4473


Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Note on breaking change: Anyone who relied on the previous undocumented behavior (“every startup clears the local Qdrant folder when on_disk is false”) will no longer get an automatic wipe. The intended behavior for a stable path is persistence. To reset, users can delete the directory manually or use a new path.


How Has This Been Tested?

  • Added test_local_path_on_disk_false_preserves_existing_directory in tests/vector_stores/test_qdrant.py: it creates a temp folder with a small file, builds Qdrant with that path and on_disk=False (with QdrantClient mocked), and checks the file is still there—so we never wipe the folder again.

  • Ran pytest tests/vector_stores/test_qdrant.py locally; all tests passed.

  • Unit Test

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Maintainer Checklist

@kartik-mem0
Copy link
Copy Markdown
Contributor

@Himanshu-Sangshetti please resolve merge conflict.

url: Optional[str] = Field(None, description="Full URL for Qdrant server")
api_key: Optional[str] = Field(None, description="API key for Qdrant server")
on_disk: Optional[bool] = Field(False, description="Enables persistent storage")
on_disk: Optional[bool] = Field(False,description="VectorParams.on_disk; does not delete local path")
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.

Minor nit. Description string can be better. Does not clearly tell what it does.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, lmk

url (str, optional): Full URL for Qdrant server. Defaults to None.
api_key (str, optional): API key for Qdrant server. Defaults to None.
on_disk (bool, optional): Enables persistent storage. Defaults to False.
on_disk (bool, optional): Qdrant ``VectorParams.on_disk``; does not delete ``path``. Defaults to False.
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.

Minor nit. Same as before

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, lmk

utkarsh240799
utkarsh240799 previously approved these changes Mar 23, 2026
Copy link
Copy Markdown
Contributor

@kartik-mem0 kartik-mem0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@kartik-mem0 kartik-mem0 merged commit ecedbc1 into mem0ai:main Mar 23, 2026
6 of 7 checks passed
jamebobob pushed a commit to jamebobob/mem0-vigil-recall that referenced this pull request Mar 29, 2026
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.

Bug Report: Qdrant Local Storage Loses Data on Restart Due to on_disk Default

3 participants