Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Move lock inside hnsw_t destructor.

Kishore Nallanf608656393c5
diff --git a/include/index.h b/include/index.h
index 1c8b7460..5f29a08c 100644
--- a/include/index.h
+++ b/include/index.h
@@ -323,6 +323,7 @@ struct hnsw_index_t {
}
~hnsw_index_t() {
+ std::lock_guard lk(repair_m);
delete vecdex;
delete space;
}
diff --git a/src/index.cpp b/src/index.cpp
index 1e712213..6af27786 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -217,7 +217,6 @@ Index::~Index() {
delete seq_ids;
for(auto& vec_index_kv: vector_index) {
- std::unique_lock lock(vec_index_kv.second->repair_m);
delete vec_index_kv.second;
}
@@ -7010,7 +7009,6 @@ void Index::refresh_schemas(const std::vector<field>& new_fields, const std::vec
if(del_field.num_dim) {
auto hnsw_index = vector_index[del_field.name];
- std::unique_lock lock(hnsw_index->repair_m);
delete hnsw_index;
vector_index.erase(del_field.name);
}