[Bug]: Local vectordb keeps a partial indexless collection when index creation fails
Local vectordb adopts a partial indexless collection when index creation fails
Bug Description
CollectionAdapter.create_collection() in openviking/storage/vectordb_adapters/base.py (shared by the local backend) attaches the backend collection before creating its index:
self._collection = self._create_backend_collection(collection_meta)
...
self._collection.create_index(index_name, index_meta)
return True
For the local backend, LocalAdapter._create_backend_collection() persists collection_meta.json under {project}/vectordb/{name}/ while constructing the collection. If create_index() then fails (engine initialization, cuVS setup, a write error, a full disk, invalid index parameters, ...), nothing is rolled back by LocalAdapter:
self._collectionstays attached, so a retry on the same adapter returnsFalsefrom thecollection_exists()guard and never creates the index.- The persisted metadata survives, so a restarted adapter (and
init_context_collection(), which reads it as an existing collection) loads an indexless collection.LocalCollection.search_by_vector()returns an empty result when the index is missing, so every later query silently returns nothing while upserts keep succeeding — data is stored but can never be retrieved.
The openGauss and pgvector adapters already treat a failed create_index as requiring compensation: they drop the partially created collection and clear the handle (opengauss_adapter.py, pgvector_adapter.py), and tests/vectordb/test_opengauss_adapter_complete.py asserts that behavior. The local backend (also used by the cuVS adapter, which inherits LocalCollectionAdapter) has no equivalent protection.
Steps to Reproduce
- Use the local vectordb backend (or the cuVS adapter, which inherits it).
- Call
create_collection()with an index configuration that makescreate_index()fail — for example invalid index parameters or a write failure at index-initialization time. - The call raises, but
{project}/vectordb/{name}/collection_meta.jsonremains on disk. - Call
create_collection()again on the same adapter: it returnsFalsefrom thecollection_exists()guard without creating the index. Restart the process and open the collection:search_by_vector()returns[]for every query whileupsert_data()keeps reporting success.
Expected Behavior
A failed create_collection() leaves no collection behind (no metadata, no directory, no attached handle), so a retry can either create the collection completely or fail cleanly.
Actual Behavior
The partially created, indexless collection persists; retries never create the index and searches silently return empty results.
Environment
- OS: Windows 11
- OpenViking version/commit: main @
b2031597
Additional Context
Fix submitted as PR #7638: LocalAdapter overrides create_collection() and, on failure, detaches and drops the partial collection (best effort, logged), removes the persisted collection directory, and re-raises the original exception. If the directory cannot be removed, the metadata file is removed so the broken collection can never be adopted later. A regression test uses a fake backend whose create_index() fails and asserts the collection is dropped, the handle is cleared, the directory is gone, collection_exists() is False, and a later attempt succeeds.