enhance: check load state before altering collection (#30399)

/kind improvement

Signed-off-by: sunby <sunbingyi1992@gmail.com>
This commit is contained in:
Bingyi Sun 2024-02-01 18:03:04 +08:00 committed by GitHub
parent 060c8603a3
commit e22e8b30d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 3 deletions

View File

@ -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(

View File

@ -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
}