mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 01:28:27 +08:00
Fix the refresh may be notified finished early (#24438)
Signed-off-by: yah01 <yah2er0ne@outlook.com>
This commit is contained in:
parent
5efa49f112
commit
848ef7418b
@ -61,7 +61,7 @@ func NewTargetManager(broker Broker, meta *Meta) *TargetManager {
|
|||||||
// UpdateCollectionCurrentTarget updates the current target to next target,
|
// 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,
|
// 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
|
// 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()
|
mgr.rwMutex.Lock()
|
||||||
defer mgr.rwMutex.Unlock()
|
defer mgr.rwMutex.Unlock()
|
||||||
log := log.With(zap.Int64("collectionID", collectionID),
|
log := log.With(zap.Int64("collectionID", collectionID),
|
||||||
@ -72,7 +72,7 @@ func (mgr *TargetManager) UpdateCollectionCurrentTarget(collectionID int64, part
|
|||||||
newTarget := mgr.next.getCollectionTarget(collectionID)
|
newTarget := mgr.next.getCollectionTarget(collectionID)
|
||||||
if newTarget == nil || newTarget.IsEmpty() {
|
if newTarget == nil || newTarget.IsEmpty() {
|
||||||
log.Info("next target does not exist, skip it")
|
log.Info("next target does not exist, skip it")
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
mgr.current.updateCollectionTarget(collectionID, newTarget)
|
mgr.current.updateCollectionTarget(collectionID, newTarget)
|
||||||
mgr.next.removeCollectionTarget(collectionID)
|
mgr.next.removeCollectionTarget(collectionID)
|
||||||
@ -80,6 +80,7 @@ func (mgr *TargetManager) UpdateCollectionCurrentTarget(collectionID int64, part
|
|||||||
log.Debug("finish to update current target for collection",
|
log.Debug("finish to update current target for collection",
|
||||||
zap.Int64s("segments", newTarget.GetAllSegmentIDs()),
|
zap.Int64s("segments", newTarget.GetAllSegmentIDs()),
|
||||||
zap.Strings("channels", newTarget.GetAllDmChannelNames()))
|
zap.Strings("channels", newTarget.GetAllDmChannelNames()))
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateCollectionNextTargetWithPartitions pulls next target from DataCoord,
|
// UpdateCollectionNextTargetWithPartitions pulls next target from DataCoord,
|
||||||
|
|||||||
@ -273,8 +273,7 @@ func (ob *TargetObserver) shouldUpdateCurrentTarget(collectionID int64) bool {
|
|||||||
|
|
||||||
func (ob *TargetObserver) updateCurrentTarget(collectionID int64) {
|
func (ob *TargetObserver) updateCurrentTarget(collectionID int64) {
|
||||||
log.Info("observer trigger update current target", zap.Int64("collectionID", collectionID))
|
log.Info("observer trigger update current target", zap.Int64("collectionID", collectionID))
|
||||||
ob.targetMgr.UpdateCollectionCurrentTarget(collectionID)
|
if ob.targetMgr.UpdateCollectionCurrentTarget(collectionID) {
|
||||||
|
|
||||||
ob.mut.Lock()
|
ob.mut.Lock()
|
||||||
defer ob.mut.Unlock()
|
defer ob.mut.Unlock()
|
||||||
notifiers := ob.readyNotifiers[collectionID]
|
notifiers := ob.readyNotifiers[collectionID]
|
||||||
@ -285,4 +284,5 @@ func (ob *TargetObserver) updateCurrentTarget(collectionID int64) {
|
|||||||
if notifiers != nil {
|
if notifiers != nil {
|
||||||
ob.readyNotifiers[collectionID] = notifiers[:0]
|
ob.readyNotifiers[collectionID] = notifiers[:0]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user