Skip to content

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

@Wadewind

Description

@Wadewind

🐛 Describe the Bug

When using Qdrant with local path storage, all data is silently deleted on every program restart if on_disk is not explicitly set to True.

🔍 Root Cause

In mem0/vector_stores/qdrant.py lines 62-67:

if not params:          # Local path mode
    params["path"] = path
    self.is_local = True
    if not on_disk:     # Defaults to False!
        if os.path.exists(path) and os.path.isdir(path):
            shutil.rmtree(path)   # ← Deletes all persisted data!

When on_disk is False (the default), the code unconditionally calls shutil.rmtree(path) to wipe the entire storage directory on every initialization. This means any data saved in a previous session is silently destroyed.

✅ Expected Behavior

Local storage should persist across restarts by default, or at minimum warn users clearly about this destructive behavior before deleting data.

❌ Actual Behavior

All memories are silently deleted every time Memory.from_config() is called without on_disk: True.

🔄 Steps to Reproduce

from mem0 import Memory

config = {
    "vector_store": {
        "provider": "qdrant",
        "config": {
            "collection_name": "memories",
            "path": "./qdrant_storage",
            "embedding_model_dims": 1024,
            # "on_disk": True  # ← Not specified, defaults to False!
        }
    }
}

# First run
m = Memory.from_config(config)
m.add("My name is Alice", user_id="alice")
print(m.get_all(user_id="alice"))  # Shows 1 memory

# Restart program...

# Second run - data is gone!
m = Memory.from_config(config)  # ← Silently deletes ./qdrant_storage/
print(m.get_all(user_id="alice"))  # Empty!

💡 Proposed Solutions

Option A (Recommended): Change default on_disk to True when path is specified:

# In qdrant.py __init__
if not on_disk and path:
    on_disk = True  # Auto-enable persistence for local storage

Option B: Never auto-delete existing directories; only create a fresh collection if explicitly requested via a new reset=True parameter:

if reset and os.path.exists(path) and os.path.isdir(path):
    shutil.rmtree(path)

Option C: At minimum, add a prominent warning log before deletion so users are not caught off guard.

📋 Environment

  • Mem0 version: 0.1.0+
  • Python: 3.8+
  • OS: Any (tested on Windows 11, Linux)

🔗 Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions