From e22e8b30d4b4a186be6d98ff688f83128f45d39e Mon Sep 17 00:00:00 2001 From: Bingyi Sun Date: Thu, 1 Feb 2024 18:03:04 +0800 Subject: [PATCH] enhance: check load state before altering collection (#30399) /kind improvement Signed-off-by: sunby --- internal/proxy/impl.go | 1 + internal/proxy/task.go | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/internal/proxy/impl.go b/internal/proxy/impl.go index e9719a088e..17ee308c3f 100644 --- a/internal/proxy/impl.go +++ b/internal/proxy/impl.go @@ -1041,6 +1041,7 @@ func (node *Proxy) AlterCollection(ctx context.Context, request *milvuspb.AlterC Condition: NewTaskCondition(ctx), AlterCollectionRequest: request, rootCoord: node.rootCoord, + queryCoord: node.queryCoord, } log := log.Ctx(ctx).With( diff --git a/internal/proxy/task.go b/internal/proxy/task.go index 9bfc6beee9..0ea432ffd6 100644 --- a/internal/proxy/task.go +++ b/internal/proxy/task.go @@ -800,9 +800,10 @@ func (t *showCollectionsTask) PostExecute(ctx context.Context) error { type alterCollectionTask struct { Condition *milvuspb.AlterCollectionRequest - ctx context.Context - rootCoord types.RootCoordClient - result *commonpb.Status + ctx context.Context + rootCoord types.RootCoordClient + result *commonpb.Status + queryCoord types.QueryCoordClient } func (t *alterCollectionTask) TraceCtx() context.Context { @@ -844,10 +845,29 @@ func (t *alterCollectionTask) OnEnqueue() error { return nil } +func hasMmapProp(props ...*commonpb.KeyValuePair) bool { + for _, p := range props { + if p.GetKey() == common.MmapEnabledKey { + return true + } + } + return false +} + func (t *alterCollectionTask) PreExecute(ctx context.Context) error { t.Base.MsgType = commonpb.MsgType_AlterCollection t.Base.SourceID = paramtable.GetNodeID() + if hasMmapProp(t.Properties...) { + loaded, err := isCollectionLoaded(ctx, t.queryCoord, t.CollectionID) + if err != nil { + return err + } + if loaded { + return merr.WrapErrCollectionLoaded(t.CollectionName, "can not alter mmap properties if collection loaded") + } + } + return nil }