Remove the unnecessary lock in the shard_cluster (#20414)

Signed-off-by: SimFG <bang.fu@zilliz.com>

Signed-off-by: SimFG <bang.fu@zilliz.com>
This commit is contained in:
SimFG 2022-11-10 10:59:04 +08:00 committed by GitHub
parent 53850e340c
commit c08657e079
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -280,9 +280,7 @@ func (sc *ShardCluster) updateSegment(evt shardSegmentInfo) {
log.Info("ShardCluster update segment", zap.Int64("nodeID", evt.nodeID), zap.Int64("segmentID", evt.segmentID), zap.Int32("state", int32(evt.state))) log.Info("ShardCluster update segment", zap.Int64("nodeID", evt.nodeID), zap.Int64("segmentID", evt.segmentID), zap.Int32("state", int32(evt.state)))
// notify handoff wait online if any // notify handoff wait online if any
defer func() { defer func() {
sc.segmentCond.L.Lock()
sc.segmentCond.Broadcast() sc.segmentCond.Broadcast()
sc.segmentCond.L.Unlock()
}() }()
sc.mut.Lock() sc.mut.Lock()
@ -358,9 +356,7 @@ func (sc *ShardCluster) SyncSegments(distribution []*querypb.ReplicaSegmentsInfo
sc.mut.Unlock() sc.mut.Unlock()
// notify handoff wait online if any // notify handoff wait online if any
sc.segmentCond.L.Lock()
sc.segmentCond.Broadcast() sc.segmentCond.Broadcast()
sc.segmentCond.L.Unlock()
sc.mutVersion.Lock() sc.mutVersion.Lock()
defer sc.mutVersion.Unlock() defer sc.mutVersion.Unlock()
@ -663,9 +659,7 @@ func (sc *ShardCluster) LoadSegments(ctx context.Context, req *querypb.LoadSegme
} }
// notify handoff wait online if any // notify handoff wait online if any
sc.segmentCond.L.Lock()
sc.segmentCond.Broadcast() sc.segmentCond.Broadcast()
sc.segmentCond.L.Unlock()
sc.mutVersion.Lock() sc.mutVersion.Lock()
defer sc.mutVersion.Unlock() defer sc.mutVersion.Unlock()