diff --git a/internal/metastore/model/collection.go b/internal/metastore/model/collection.go index 66acf68cf248c..08f6cf08ff1c0 100644 --- a/internal/metastore/model/collection.go +++ b/internal/metastore/model/collection.go @@ -34,6 +34,29 @@ func (c *Collection) Available() bool { return c.State == pb.CollectionState_CollectionCreated } +func (c *Collection) ShadowClone() *Collection { + return &Collection{ + TenantID: c.TenantID, + DBID: c.DBID, + CollectionID: c.CollectionID, + Name: c.Name, + Description: c.Description, + AutoID: c.AutoID, + Fields: c.Fields, + Partitions: c.Partitions, + VirtualChannelNames: c.VirtualChannelNames, + PhysicalChannelNames: c.PhysicalChannelNames, + ShardsNum: c.ShardsNum, + ConsistencyLevel: c.ConsistencyLevel, + CreateTime: c.CreateTime, + StartPositions: c.StartPositions, + Aliases: c.Aliases, + Properties: c.Properties, + State: c.State, + EnableDynamicField: c.EnableDynamicField, + } +} + func (c *Collection) Clone() *Collection { return &Collection{ TenantID: c.TenantID, diff --git a/internal/rootcoord/meta_table.go b/internal/rootcoord/meta_table.go index 8616ce6dc9092..f84055d5495ec 100644 --- a/internal/rootcoord/meta_table.go +++ b/internal/rootcoord/meta_table.go @@ -537,12 +537,12 @@ func (mt *MetaTable) RemoveCollection(ctx context.Context, collectionID UniqueID } func filterUnavailable(coll *model.Collection) *model.Collection { - clone := coll.Clone() + clone := coll.ShadowClone() // pick available partitions. - clone.Partitions = nil + clone.Partitions = make([]*model.Partition, 0, len(coll.Partitions)) for _, partition := range coll.Partitions { if partition.Available() { - clone.Partitions = append(clone.Partitions, partition.Clone()) + clone.Partitions = append(clone.Partitions, partition) } } return clone