From 78fd1987ebb817ec27b69a380cb0004e241ac083 Mon Sep 17 00:00:00 2001 From: yah01 Date: Tue, 17 Jan 2023 18:11:42 +0800 Subject: [PATCH] Fix data race caused by no clone while updating index (#21772) Signed-off-by: yah01 --- internal/datacoord/segment_info.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/datacoord/segment_info.go b/internal/datacoord/segment_info.go index 6b5627c074..4b061c3920 100644 --- a/internal/datacoord/segment_info.go +++ b/internal/datacoord/segment_info.go @@ -109,10 +109,12 @@ func (s *SegmentsInfo) SetSegmentIndex(segmentID UniqueID, segIndex *model.Segme ) return } + segment = segment.Clone() if segment.segmentIndexes == nil { segment.segmentIndexes = make(map[UniqueID]*model.SegmentIndex) } segment.segmentIndexes[segIndex.IndexID] = segIndex + s.segments[segmentID] = segment } func (s *SegmentsInfo) DropSegmentIndex(segmentID UniqueID, indexID UniqueID) {