fix: [2.5] Check collection released before target checks (#39843)

Cherry-pick from master
pr: #39841 
Related to #39840

The target could be updated async in previous code. This PR make remove
collection from target observer block until all tasks related in
dispatchers are removed preventing the metrics being updated after
collection released.

---------

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/39839/head
congqixia 2025-02-13 20:00:15 +08:00 committed by GitHub
parent f85bf59921
commit 9407a3c9b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -219,7 +219,9 @@ func (ob *TargetObserver) schedule(ctx context.Context) {
delete(ob.readyNotifiers, req.CollectionID)
ob.mut.Unlock()
ob.keylocks.Lock(req.CollectionID)
ob.targetMgr.RemoveCollection(ctx, req.CollectionID)
ob.keylocks.Unlock(req.CollectionID)
req.Notifier <- nil
case ReleasePartition:
ob.targetMgr.RemovePartition(ctx, req.CollectionID, req.PartitionIDs...)
@ -250,6 +252,11 @@ func (ob *TargetObserver) check(ctx context.Context, collectionID int64) {
ob.keylocks.Lock(collectionID)
defer ob.keylocks.Unlock(collectionID)
// if collection release, skip check
if ob.meta.CollectionManager.GetCollection(ctx, collectionID) == nil {
return
}
if ob.shouldUpdateCurrentTarget(ctx, collectionID) {
ob.updateCurrentTarget(ctx, collectionID)
}