Add warning comments (#21697)

Signed-off-by: yah01 <yang.cen@zilliz.com>
pull/21712/head
yah01 2023-01-13 16:43:41 +08:00 committed by GitHub
parent c0e7a122d4
commit c66ce4aeba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -219,6 +219,7 @@ func (job *LoadCollectionJob) Execute() error {
return utils.WrapError(msg, err) return utils.WrapError(msg, err)
} }
// It's safe here to call UpdateCollectionNextTargetWithPartitions, as the collection not existing
err = job.targetMgr.UpdateCollectionNextTargetWithPartitions(req.GetCollectionID(), partitionIDs...) err = job.targetMgr.UpdateCollectionNextTargetWithPartitions(req.GetCollectionID(), partitionIDs...)
if err != nil { if err != nil {
msg := "failed to update next targets for collection" msg := "failed to update next targets for collection"
@ -420,6 +421,7 @@ func (job *LoadPartitionJob) Execute() error {
zap.Int64s("nodes", replica.GetNodes())) zap.Int64s("nodes", replica.GetNodes()))
} }
// It's safe here to call UpdateCollectionNextTargetWithPartitions, as the collection not existing
err = job.targetMgr.UpdateCollectionNextTargetWithPartitions(req.GetCollectionID(), req.GetPartitionIDs()...) err = job.targetMgr.UpdateCollectionNextTargetWithPartitions(req.GetCollectionID(), req.GetPartitionIDs()...)
if err != nil { if err != nil {
msg := "failed to update next targets for collection" msg := "failed to update next targets for collection"

View File

@ -56,6 +56,9 @@ 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) {
mgr.rwMutex.Lock() mgr.rwMutex.Lock()
defer mgr.rwMutex.Unlock() defer mgr.rwMutex.Unlock()
@ -77,7 +80,9 @@ func (mgr *TargetManager) UpdateCollectionCurrentTarget(collectionID int64, part
zap.Strings("channels", newTarget.GetAllDmChannelNames())) zap.Strings("channels", newTarget.GetAllDmChannelNames()))
} }
// UpdateCollectionNextTargetWithPartitions for collection_loading request, which offer partitionIDs outside // UpdateCollectionNextTargetWithPartitions pulls next target from DataCoord,
// 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) UpdateCollectionNextTargetWithPartitions(collectionID int64, partitionIDs ...int64) error { func (mgr *TargetManager) UpdateCollectionNextTargetWithPartitions(collectionID int64, partitionIDs ...int64) error {
mgr.rwMutex.Lock() mgr.rwMutex.Lock()
defer mgr.rwMutex.Unlock() defer mgr.rwMutex.Unlock()
@ -93,7 +98,9 @@ func (mgr *TargetManager) UpdateCollectionNextTargetWithPartitions(collectionID
return mgr.updateCollectionNextTarget(collectionID, partitionIDs...) return mgr.updateCollectionNextTarget(collectionID, partitionIDs...)
} }
// UpdateCollectionNextTarget for collection_loaded request, which use partition info from meta or broker // UpdateCollectionNextTarget updates the next target with new target pulled from DataCoord,
// 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) UpdateCollectionNextTarget(collectionID int64) error { func (mgr *TargetManager) UpdateCollectionNextTarget(collectionID int64) error {
mgr.rwMutex.Lock() mgr.rwMutex.Lock()
defer mgr.rwMutex.Unlock() defer mgr.rwMutex.Unlock()