Skip to content

Commit

Permalink
enhance: [10kcp] Reducing the granularity of locks in the target mana…
Browse files Browse the repository at this point in the history
…ger (#38956)

pr: #38566

Just for test, I'll remove the global mutex latter.

Signed-off-by: bigsheeper <[email protected]>
  • Loading branch information
bigsheeper authored Jan 2, 2025
1 parent 7934c21 commit 663ec6f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/querycoordv2/meta/target_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ func (mgr *TargetManager) UpdateCollectionNextTarget(collectionID int64) error {
return err
}

mgr.rwMutex.Lock()
defer mgr.rwMutex.Unlock()
partitions := mgr.meta.GetPartitionsByCollection(collectionID)
partitionIDs := lo.Map(partitions, func(partition *Partition, i int) int64 {
return partition.PartitionID
Expand Down Expand Up @@ -183,7 +181,7 @@ func (mgr *TargetManager) UpdateCollectionNextTarget(collectionID int64) error {
}

for _, infos := range channelInfos {
merged := mgr.mergeDmChannelInfo(infos)
merged := mergeDmChannelInfo(infos)
dmChannels[merged.GetChannelName()] = merged
}

Expand All @@ -193,15 +191,19 @@ func (mgr *TargetManager) UpdateCollectionNextTarget(collectionID int64) error {
}

allocatedTarget := NewCollectionTarget(segments, dmChannels, partitionIDs)

mgr.rwMutex.Lock()
mgr.next.updateCollectionTarget(collectionID, allocatedTarget)
mgr.rwMutex.Unlock()

log.Debug("finish to update next targets for collection",
zap.Int64("collectionID", collectionID),
zap.Int64s("PartitionIDs", partitionIDs))

return nil
}

func (mgr *TargetManager) mergeDmChannelInfo(infos []*datapb.VchannelInfo) *DmChannel {
func mergeDmChannelInfo(infos []*datapb.VchannelInfo) *DmChannel {
var dmChannel *DmChannel

for _, info := range infos {
Expand Down

0 comments on commit 663ec6f

Please sign in to comment.