mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
enhance: check load state before altering collection (#30399)
/kind improvement Signed-off-by: sunby <sunbingyi1992@gmail.com>
This commit is contained in:
parent
060c8603a3
commit
e22e8b30d4
@ -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(
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user