Skip to content

Commit

Permalink
fix: Check collection released before target checks (#39841)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
congqixia authored Feb 14, 2025
1 parent 9bbaaac commit 58045a3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/querycoordv2/observers/target_observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 58045a3

Please sign in to comment.