fix: SealedIndexingEntry in SealedIndexingRecord may leak without smart pointer protect. (#29932)

may related issue: #29828

Signed-off-by: chyezh <ye.zhen@zilliz.com>
pull/29665/head
chyezh 2024-01-14 10:28:51 +08:00 committed by GitHub
parent d9edd50f97
commit def717af55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -37,6 +37,7 @@ SearchOnSealedIndex(const Schema& schema,
auto dim = field.get_dim();
AssertInfo(record.is_ready(field_id), "[SearchOnSealed]Record isn't ready");
// Keep the field_indexing smart pointer, until all reference by raw dropped.
auto field_indexing = record.get_field_indexing(field_id);
AssertInfo(field_indexing->metric_type_ == search_info.metric_type_,
"Metric type of field index isn't the same with search info");

View File

@ -29,7 +29,7 @@ struct SealedIndexingEntry {
index::IndexBasePtr indexing_;
};
using SealedIndexingEntryPtr = std::unique_ptr<SealedIndexingEntry>;
using SealedIndexingEntryPtr = std::shared_ptr<SealedIndexingEntry>;
struct SealedIndexingRecord {
void
@ -43,11 +43,11 @@ struct SealedIndexingRecord {
field_indexings_[field_id] = std::move(ptr);
}
const SealedIndexingEntry*
const SealedIndexingEntryPtr
get_field_indexing(FieldId field_id) const {
std::shared_lock lck(mutex_);
AssertInfo(field_indexings_.count(field_id), "field_id not found");
return field_indexings_.at(field_id).get();
return field_indexings_.at(field_id);
}
void