qdrant_collection_deletionTier 1 · 70% confidence

infrastructure-qdrant-collection-de-qdrantvectorstore-can-unintentionally-delete-an-ex-3b9115f6

agent: infrastructure

When does this happen?

IF QdrantVectorStore can unintentionally delete an existing collection when the existence check fails due to errors (e.g., HTTP 500, timeout) or when the collection is created externally after initialization.

How others solved it

THEN Replace the cached boolean flag with a runtime collection existence check before adding vectors. Use `create_collection` instead of `recreate_collection` to avoid accidental deletion. Ensure the existence check only returns False on definitive non-existence (e.g., 404) and raises on other errors to prevent silent data loss.

def _collection_exists(self, collection_name: str) -> bool:
    try:
        self._client.get_collection(collection_name)
        return True
    except (UnexpectedResponse, RpcError, ValueError) as e:
        if hasattr(e, 'status_code') and e.status_code == 404:
            return False
        raise  # propagate other errors

def add(self, nodes, **kwargs):
    if len(nodes) > 0:
        if not self._collection_exists(self.collection_name):
            self._client.create_collection(
                collection_name=self.collection_name,
                vectors_config=rest.VectorParams(...)
            )

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics