enhance: Remove unnecessary clone in SetState (#37697)

issue: https://github.com/milvus-io/milvus/issues/37637

---------

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
pull/37724/head
yihao.dai 2024-11-15 15:06:30 +08:00 committed by GitHub
parent 81fa7dd52c
commit 18a64782dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 11 deletions

View File

@ -642,7 +642,7 @@ func (m *meta) SetState(segmentID UniqueID, targetState commonpb.SegmentState) e
// Apply segment metric update after successful meta update.
metricMutation.commit()
// Update in-memory meta.
m.segments.SetState(segmentID, targetState)
m.segments.SetSegment(segmentID, clonedSegment)
}
log.Info("meta update: setting segment state - complete",
zap.Int64("segmentID", segmentID),

View File

@ -219,14 +219,6 @@ func (s *SegmentsInfo) SetRowCount(segmentID UniqueID, rowCount int64) {
}
}
// SetState sets Segment State info for SegmentInfo with provided segmentID
// if SegmentInfo not found, do nothing
func (s *SegmentsInfo) SetState(segmentID UniqueID, state commonpb.SegmentState) {
if segment, ok := s.segments[segmentID]; ok {
s.segments[segmentID] = segment.Clone(SetState(state))
}
}
// SetDmlPosition sets DmlPosition info (checkpoint for recovery) for SegmentInfo with provided segmentID
// if SegmentInfo not found, do nothing
func (s *SegmentsInfo) SetDmlPosition(segmentID UniqueID, pos *msgpb.MsgPosition) {

View File

@ -546,10 +546,12 @@ func (s *statsTaskSuite) TestTaskStats_PreCheck() {
s.Run("normal case", func() {
catalog := catalogmocks.NewDataCoordCatalog(s.T())
catalog.EXPECT().AlterSegments(mock.Anything, mock.Anything, mock.Anything).Return(nil)
s.mt.catalog = catalog
s.mt.statsTaskMeta.catalog = catalog
s.mt.segments.SetState(s.segID, commonpb.SegmentState_Flushed)
catalog.EXPECT().AlterSegments(mock.Anything, mock.Anything, mock.Anything).Return(nil)
updateStateOp := UpdateStatusOperator(s.segID, commonpb.SegmentState_Flushed)
err := s.mt.UpdateSegmentsInfo(updateStateOp)
s.NoError(err)
catalog.EXPECT().SaveStatsTask(mock.Anything, mock.Anything).Return(nil)
s.NoError(st.SetJobInfo(s.mt))