fix: fixup data race at generate binlog index (#29370)

issue: #29339

Signed-off-by: chyezh <ye.zhen@zilliz.com>
This commit is contained in:
chyezh 2023-12-21 14:58:49 +08:00 committed by GitHub
parent 48f506b077
commit be87c18b44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1455,7 +1455,13 @@ SegmentSealedImpl::generate_binlog_index(const FieldId field_id) {
// get binlog data and meta
auto row_count = num_rows_.value();
auto dim = field_meta.get_dim();
auto vec_data = fields_.at(field_id);
std::shared_ptr<ColumnBase> vec_data{};
{
// field should be exists.
// otherwise, out_of_range exception is thrown by fields_.at
std::shared_lock lck(mutex_);
vec_data = fields_.at(field_id);
}
auto dataset =
knowhere::GenDataSet(row_count, dim, (void*)vec_data->Data());
dataset->SetIsOwner(false);