Skip to content

Commit

Permalink
fix: [2.4] fill the metric type field in the LoadMetaInfo object (mil…
Browse files Browse the repository at this point in the history
…vus-io#35963)

- issue: milvus-io#35960
- pr: milvus-io#35962

Signed-off-by: SimFG <[email protected]>
  • Loading branch information
SimFG authored Sep 4, 2024
1 parent 2c1fa50 commit 084b3ef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion internal/core/src/query/SearchOnSealed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ SearchOnSealedIndex(const Schema& schema,
// 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");
"Metric type of field index isn't the same with search info,"
"field index: {}, search info: {}", field_indexing->metric_type_, search_info.metric_type_);

auto dataset = knowhere::GenDataSet(num_queries, dim, query_data);
dataset->SetIsSparse(is_sparse);
Expand Down
2 changes: 1 addition & 1 deletion internal/core/src/segcore/ConcurrentVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ThreadSafeVector {

int64_t
size() const {
std::lock_guard lck(mutex_);
std::shared_lock lck(mutex_);
return size_;
}

Expand Down
17 changes: 17 additions & 0 deletions internal/querycoordv2/task/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
. "github.com/milvus-io/milvus/internal/querycoordv2/params"
"github.com/milvus-io/milvus/internal/querycoordv2/session"
"github.com/milvus-io/milvus/internal/querycoordv2/utils"
"github.com/milvus-io/milvus/pkg/common"
"github.com/milvus-io/milvus/pkg/log"
"github.com/milvus-io/milvus/pkg/util/commonpbutil"
"github.com/milvus-io/milvus/pkg/util/funcutil"
Expand Down Expand Up @@ -197,6 +198,8 @@ func (ex *Executor) loadSegment(task *SegmentTask, step int) error {
return err
}

ex.setMetricTypeForMetaInfo(loadMeta, indexInfos)

req := packLoadSegmentRequest(
task,
action,
Expand Down Expand Up @@ -550,6 +553,8 @@ func (ex *Executor) setDistribution(task *LeaderTask, step int) error {
return err
}

ex.setMetricTypeForMetaInfo(loadMeta, indexInfo)

req := &querypb.SyncDistributionRequest{
Base: commonpbutil.NewMsgBase(
commonpbutil.WithMsgType(commonpb.MsgType_LoadSegments),
Expand Down Expand Up @@ -722,3 +727,15 @@ func (ex *Executor) getLoadInfo(ctx context.Context, collectionID, segmentID int
loadInfo := utils.PackSegmentLoadInfo(segment, channel.GetSeekPosition(), indexes)
return loadInfo, indexInfos, nil
}

// setMetricTypeForMetaInfo it's a compatibility method for rolling upgrade from 2.3.x to 2.4
func (ex *Executor) setMetricTypeForMetaInfo(metaInfo *querypb.LoadMetaInfo, indexInfos []*indexpb.IndexInfo) {
for _, info := range indexInfos {
for _, param := range info.IndexParams {
if param.GetKey() == common.MetricTypeKey {
metaInfo.MetricType = param.GetValue()
return
}
}
}
}

0 comments on commit 084b3ef

Please sign in to comment.