fix: HNSW schema deleting document crash (#4987)

fixed: https://github.com/dragonflydb/dragonfly/issues/4979
This commit is contained in:
Volodymyr Yavdoshenko 2025-04-28 14:01:04 +03:00 committed by GitHub
parent 5ea3070abf
commit 2128eb31c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View file

@ -281,7 +281,10 @@ struct HnswlibAdapter {
}
void Remove(DocId id) {
world_.markDelete(id);
try {
world_.markDelete(id);
} catch (const std::exception& e) {
}
}
vector<pair<float, DocId>> Knn(float* target, size_t k, std::optional<size_t> ef) {

View file

@ -2722,6 +2722,18 @@ TEST_F(SearchFamilyTest, JsonWithNullFields) {
AreDocIds("doc:1", "doc:2"));
}
TEST_F(SearchFamilyTest, TestHsetDeleteDocumentHnswSchemaCrash) {
EXPECT_EQ(Run({"FT.CREATE", "idx", "SCHEMA", "n", "NUMERIC", "v", "VECTOR", "HNSW", "8", "TYPE",
"FLOAT16", "DIM", "4", "DISTANCE_METRIC", "L2", "M", "65536"}),
"OK");
auto res = Run({"HSET", "doc", "n", "0"});
EXPECT_EQ(res, 1);
res = Run({"DEL", "doc"});
EXPECT_EQ(res, 1);
}
TEST_F(SearchFamilyTest, RenameDocumentBetweenIndices) {
absl::FlagSaver fs;