Skip to content

Commit

Permalink
fix: Add defer Unpin when error happens (#36620)
Browse files Browse the repository at this point in the history
Resolves: #36619

---------

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
  • Loading branch information
congqixia authored Sep 30, 2024
1 parent 2055df8 commit ddc3e76
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/querynodev2/segments/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ func validate(ctx context.Context, manager *Manager, collectionID int64, partiti
// validate segment
segments := make([]Segment, 0, len(segmentIDs))
var err error
defer func() {
if err != nil {
manager.Segment.Unpin(segments)
}
}()
if len(segmentIDs) == 0 {
for _, partID := range searchPartIDs {
segments, err = manager.Segment.GetAndPinBy(WithPartition(partID), segmentFilter)
Expand All @@ -76,7 +81,7 @@ func validate(ctx context.Context, manager *Manager, collectionID int64, partiti
}
for _, segment := range segments {
if !funcutil.SliceContain(searchPartIDs, segment.Partition()) {
err := fmt.Errorf("segment %d belongs to partition %d, which is not in %v", segment.ID(), segment.Partition(), searchPartIDs)
err = fmt.Errorf("segment %d belongs to partition %d, which is not in %v", segment.ID(), segment.Partition(), searchPartIDs)
return nil, err
}
}
Expand Down

0 comments on commit ddc3e76

Please # to comment.