From c15290c12586557f97ea3c9cf0cc6af8eb86cd28 Mon Sep 17 00:00:00 2001 From: "yihao.dai" Date: Mon, 15 Sep 2025 10:27:58 +0800 Subject: [PATCH] fix: Fix invalid pre-allocated segment IDs (#44350) Mark the task as failed when PreAllocatedSegmentIDs is nil. issue: https://github.com/milvus-io/milvus/issues/44349 Signed-off-by: bigsheeper --- internal/datacoord/compaction_task_meta.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/internal/datacoord/compaction_task_meta.go b/internal/datacoord/compaction_task_meta.go index d635a83429..708990a2b7 100644 --- a/internal/datacoord/compaction_task_meta.go +++ b/internal/datacoord/compaction_task_meta.go @@ -18,6 +18,7 @@ package datacoord import ( "context" + "fmt" "strconv" "sync" "time" @@ -86,12 +87,16 @@ func (csm *compactionTaskMeta) reloadFromKV() error { return err } for _, task := range compactionTasks { - // To maintain compatibility with versions ≤v2.4.12, which use `ResultSegments` as preallocate segment IDs. - if task.PreAllocatedSegmentIDs == nil && len(task.GetResultSegments()) == 2 { - task.PreAllocatedSegmentIDs = &datapb.IDRange{ - Begin: task.GetResultSegments()[0], - End: task.GetResultSegments()[1], - } + // Compatibility handling: for milvus ≤v2.4, since compaction task has no PreAllocatedSegmentIDs field, + // here we just mark the task as failed and wait for the compaction trigger to generate a new one. + if task.PreAllocatedSegmentIDs == nil { + log.Warn("PreAllocatedSegmentIDs is nil, mark the task as failed", + zap.Int64("taskID", task.GetPlanID()), + zap.String("type", task.GetType().String()), + zap.String("originalState", task.State.String()), + ) + task.State = datapb.CompactionTaskState_failed + task.FailReason = fmt.Sprintf("PreAllocatedSegmentIDs is nil, taskID: %v", task.GetPlanID()) } csm.saveCompactionTaskMemory(task) }