Skip to content

Commit

Permalink
fix: [10kcp] Fix rootcoord meta mutex contention (milvus-io#38803)
Browse files Browse the repository at this point in the history
RootCoord meta uses copy-on-write, allowing the removal of unnecessary
copies.

issue: milvus-io#37630

pr: milvus-io#38799

Signed-off-by: bigsheeper <[email protected]>
  • Loading branch information
bigsheeper authored Dec 27, 2024
1 parent e13b8a2 commit 4d0594b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
23 changes: 23 additions & 0 deletions internal/metastore/model/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions internal/rootcoord/meta_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4d0594b

Please sign in to comment.