Skip to content

Commit

Permalink
fix: remove the mmap.enable param in the type param when creating ind…
Browse files Browse the repository at this point in the history
…ex (#39803)

Because when GetIndexParams is used, index params and type params are
concatenated, so when loading index, the mmap.enable parameter in type
params is also referenced.

- issue: #39801

Signed-off-by: SimFG <[email protected]>
  • Loading branch information
SimFG authored Feb 13, 2025
1 parent 3e5f349 commit 407c4b4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
8 changes: 5 additions & 3 deletions internal/datacoord/index_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,15 @@ func (m *indexMeta) updateIndexTasksMetrics() {
}

func checkParams(fieldIndex *model.Index, req *indexpb.CreateIndexRequest) bool {
if len(fieldIndex.TypeParams) != len(req.TypeParams) {
metaTypeParams := DeleteParams(fieldIndex.TypeParams, []string{common.MmapEnabledKey})
reqTypeParams := DeleteParams(req.TypeParams, []string{common.MmapEnabledKey})
if len(metaTypeParams) != len(reqTypeParams) {
return false
}
notEq := false
for _, param1 := range fieldIndex.TypeParams {
for _, param1 := range metaTypeParams {
exist := false
for _, param2 := range req.TypeParams {
for _, param2 := range reqTypeParams {
if param2.Key == param1.Key && param2.Value == param1.Value {
exist = true
}
Expand Down
4 changes: 4 additions & 0 deletions internal/datacoord/index_meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@ func TestMeta_HasSameReq(t *testing.T) {
Key: common.DimKey,
Value: "128",
},
{
Key: common.MmapEnabledKey,
Value: "true",
},
}
indexParams = []*commonpb.KeyValuePair{
{
Expand Down
11 changes: 7 additions & 4 deletions internal/datacoord/index_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/milvus-io/milvus/internal/metastore/model"
"github.com/milvus-io/milvus/internal/util/indexparamcheck"
"github.com/milvus-io/milvus/internal/util/vecindexmgr"
"github.com/milvus-io/milvus/pkg/common"
pkgcommon "github.com/milvus-io/milvus/pkg/common"
"github.com/milvus-io/milvus/pkg/log"
"github.com/milvus-io/milvus/pkg/metrics"
Expand Down Expand Up @@ -243,13 +244,15 @@ func (s *Server) CreateIndex(ctx context.Context, req *indexpb.CreateIndexReques
return merr.Status(err), nil
}
}
// exclude the mmap.enable param, because it will be conflict with the index's mmap.enable param
typeParams := DeleteParams(req.GetTypeParams(), []string{common.MmapEnabledKey})

index := &model.Index{
CollectionID: req.GetCollectionID(),
FieldID: req.GetFieldID(),
IndexID: indexID,
IndexName: req.GetIndexName(),
TypeParams: req.GetTypeParams(),
TypeParams: typeParams,
IndexParams: req.GetIndexParams(),
CreateTime: req.GetTimestamp(),
IsAutoIndex: req.GetIsAutoIndex(),
Expand Down Expand Up @@ -340,7 +343,7 @@ func UpdateParams(index *model.Index, from []*commonpb.KeyValuePair, updates []*
})
}

func DeleteParams(index *model.Index, from []*commonpb.KeyValuePair, deletes []string) []*commonpb.KeyValuePair {
func DeleteParams(from []*commonpb.KeyValuePair, deletes []string) []*commonpb.KeyValuePair {
params := make(map[string]string)
for _, param := range from {
params[param.GetKey()] = param.GetValue()
Expand Down Expand Up @@ -431,15 +434,15 @@ func (s *Server) AlterIndex(ctx context.Context, req *indexpb.AlterIndexRequest)
index.IndexParams = newIndexParams
} else if len(req.GetDeleteKeys()) > 0 {
// delete user index params
newUserIndexParams := DeleteParams(index, index.UserIndexParams, req.GetDeleteKeys())
newUserIndexParams := DeleteParams(index.UserIndexParams, req.GetDeleteKeys())
log.Info("alter index user deletekeys",
zap.String("indexName", index.IndexName),
zap.Any("params", newUserIndexParams),
)
index.UserIndexParams = newUserIndexParams

// delete index params
newIndexParams := DeleteParams(index, index.IndexParams, req.GetDeleteKeys())
newIndexParams := DeleteParams(index.IndexParams, req.GetDeleteKeys())
log.Info("alter index index deletekeys",
zap.String("indexName", index.IndexName),
zap.Any("params", newIndexParams),
Expand Down

0 comments on commit 407c4b4

Please sign in to comment.