Fix data race caused by no clone while updating index (#21772)

Signed-off-by: yah01 <yang.cen@zilliz.com>
pull/21776/head
yah01 2023-01-17 18:11:42 +08:00 committed by GitHub
parent ad6cbc990f
commit 78fd1987eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -109,10 +109,12 @@ func (s *SegmentsInfo) SetSegmentIndex(segmentID UniqueID, segIndex *model.Segme
) )
return return
} }
segment = segment.Clone()
if segment.segmentIndexes == nil { if segment.segmentIndexes == nil {
segment.segmentIndexes = make(map[UniqueID]*model.SegmentIndex) segment.segmentIndexes = make(map[UniqueID]*model.SegmentIndex)
} }
segment.segmentIndexes[segIndex.IndexID] = segIndex segment.segmentIndexes[segIndex.IndexID] = segIndex
s.segments[segmentID] = segment
} }
func (s *SegmentsInfo) DropSegmentIndex(segmentID UniqueID, indexID UniqueID) { func (s *SegmentsInfo) DropSegmentIndex(segmentID UniqueID, indexID UniqueID) {