mirror of https://github.com/milvus-io/milvus.git
Fix the refresh may be notified finished early (#24438)
Signed-off-by: yah01 <yah2er0ne@outlook.com>pull/24455/head
parent
5efa49f112
commit
848ef7418b
|
@ -61,7 +61,7 @@ func NewTargetManager(broker Broker, meta *Meta) *TargetManager {
|
|||
// UpdateCollectionCurrentTarget updates the current target to next target,
|
||||
// WARN: DO NOT call this method for an existing collection as target observer running, or it will lead to a double-update,
|
||||
// which may make the current target not available
|
||||
func (mgr *TargetManager) UpdateCollectionCurrentTarget(collectionID int64, partitionIDs ...int64) {
|
||||
func (mgr *TargetManager) UpdateCollectionCurrentTarget(collectionID int64, partitionIDs ...int64) bool {
|
||||
mgr.rwMutex.Lock()
|
||||
defer mgr.rwMutex.Unlock()
|
||||
log := log.With(zap.Int64("collectionID", collectionID),
|
||||
|
@ -72,7 +72,7 @@ func (mgr *TargetManager) UpdateCollectionCurrentTarget(collectionID int64, part
|
|||
newTarget := mgr.next.getCollectionTarget(collectionID)
|
||||
if newTarget == nil || newTarget.IsEmpty() {
|
||||
log.Info("next target does not exist, skip it")
|
||||
return
|
||||
return false
|
||||
}
|
||||
mgr.current.updateCollectionTarget(collectionID, newTarget)
|
||||
mgr.next.removeCollectionTarget(collectionID)
|
||||
|
@ -80,6 +80,7 @@ func (mgr *TargetManager) UpdateCollectionCurrentTarget(collectionID int64, part
|
|||
log.Debug("finish to update current target for collection",
|
||||
zap.Int64s("segments", newTarget.GetAllSegmentIDs()),
|
||||
zap.Strings("channels", newTarget.GetAllDmChannelNames()))
|
||||
return true
|
||||
}
|
||||
|
||||
// UpdateCollectionNextTargetWithPartitions pulls next target from DataCoord,
|
||||
|
|
|
@ -273,16 +273,16 @@ func (ob *TargetObserver) shouldUpdateCurrentTarget(collectionID int64) bool {
|
|||
|
||||
func (ob *TargetObserver) updateCurrentTarget(collectionID int64) {
|
||||
log.Info("observer trigger update current target", zap.Int64("collectionID", collectionID))
|
||||
ob.targetMgr.UpdateCollectionCurrentTarget(collectionID)
|
||||
|
||||
ob.mut.Lock()
|
||||
defer ob.mut.Unlock()
|
||||
notifiers := ob.readyNotifiers[collectionID]
|
||||
for _, notifier := range notifiers {
|
||||
close(notifier)
|
||||
}
|
||||
// Reuse the capacity of notifiers slice
|
||||
if notifiers != nil {
|
||||
ob.readyNotifiers[collectionID] = notifiers[:0]
|
||||
if ob.targetMgr.UpdateCollectionCurrentTarget(collectionID) {
|
||||
ob.mut.Lock()
|
||||
defer ob.mut.Unlock()
|
||||
notifiers := ob.readyNotifiers[collectionID]
|
||||
for _, notifier := range notifiers {
|
||||
close(notifier)
|
||||
}
|
||||
// Reuse the capacity of notifiers slice
|
||||
if notifiers != nil {
|
||||
ob.readyNotifiers[collectionID] = notifiers[:0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue