fix: Release data memory after sync task completes (#42627)

Release data memory after sync task completes to prevent datanode oom
during import.

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

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
This commit is contained in:
yihao.dai 2025-06-10 16:28:34 +08:00 committed by GitHub
parent c9680a5b56
commit ed55b14484
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 0 deletions

View File

@ -143,3 +143,9 @@ func (p *SyncPack) WithDataSource(source string) *SyncPack {
p.dataSource = source
return p
}
func (p *SyncPack) ReleaseData() {
p.insertData = nil
p.deltaData = nil
p.bm25Stats = nil
}

View File

@ -168,6 +168,8 @@ func (t *SyncTask) Run(ctx context.Context) (err error) {
}
}
t.pack.ReleaseData()
actions := []metacache.SegmentAction{metacache.FinishSyncing(t.batchRows)}
if t.pack.isFlush {
actions = append(actions, metacache.UpdateState(commonpb.SegmentState_Flushed))

View File

@ -210,6 +210,12 @@ func (s *SyncTaskSuite) runTestRunNormal(storageVersion int64) {
action(seg)
}).Return()
isDataReleased := func(task *SyncTask) bool {
return task.pack.insertData == nil &&
task.pack.deltaData == nil &&
task.pack.bm25Stats == nil
}
s.Run("without_data", func() {
task := s.getSuiteSyncTask(new(SyncPack).WithCheckpoint(
&msgpb.MsgPosition{
@ -225,6 +231,7 @@ func (s *SyncTaskSuite) runTestRunNormal(storageVersion int64) {
err := task.Run(ctx)
s.NoError(err)
s.True(isDataReleased(task)) // data should be released after task finished
})
s.Run("with_insert_delete_cp", func() {
@ -244,6 +251,7 @@ func (s *SyncTaskSuite) runTestRunNormal(storageVersion int64) {
err := task.Run(ctx)
s.NoError(err)
s.True(isDataReleased(task)) // data should be released after task finished
})
s.Run("with_flush", func() {
@ -263,6 +271,7 @@ func (s *SyncTaskSuite) runTestRunNormal(storageVersion int64) {
}
err := task.Run(ctx)
s.NoError(err)
s.True(isDataReleased(task)) // data should be released after task finished
})
s.Run("with_drop", func() {
@ -282,6 +291,7 @@ func (s *SyncTaskSuite) runTestRunNormal(storageVersion int64) {
}
err := task.Run(ctx)
s.NoError(err)
s.True(isDataReleased(task)) // data should be released after task finished
})
}