From c3e26a35f568b3e0c32e45879d76685d5d4823e0 Mon Sep 17 00:00:00 2001 From: "cai.zhang" Date: Tue, 31 Dec 2024 10:28:53 +0800 Subject: [PATCH] fix: [2.4] Release compaction task lock when return function (#38857) issue: #38851 master pr: #38856 Signed-off-by: Cai Zhang --- internal/datacoord/compaction.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/datacoord/compaction.go b/internal/datacoord/compaction.go index a25d45a501625..fbda48622d816 100644 --- a/internal/datacoord/compaction.go +++ b/internal/datacoord/compaction.go @@ -206,12 +206,6 @@ func (c *compactionPlanHandler) schedule() []CompactionTask { slots map[int64]int64 ) - c.executingGuard.Lock() - if len(c.executingTasks) >= parallelism { - return selected - } - c.executingGuard.Unlock() - l0ChannelExcludes := typeutil.NewSet[string]() mixChannelExcludes := typeutil.NewSet[string]() clusterChannelExcludes := typeutil.NewSet[string]() @@ -219,6 +213,11 @@ func (c *compactionPlanHandler) schedule() []CompactionTask { clusterLabelExcludes := typeutil.NewSet[string]() c.executingGuard.RLock() + if len(c.executingTasks) >= parallelism { + c.executingGuard.RUnlock() + return selected + } + for _, t := range c.executingTasks { switch t.GetType() { case datapb.CompactionType_Level0DeleteCompaction: