From 303b59044aa5bc78e7ad4aa28ee33862b5586422 Mon Sep 17 00:00:00 2001 From: Cai Zhang Date: Mon, 30 Dec 2024 20:30:10 +0800 Subject: [PATCH] Release lock when return function 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 c1f58b94d414d..0fe51c6496efe 100644 --- a/internal/datacoord/compaction.go +++ b/internal/datacoord/compaction.go @@ -212,12 +212,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]() @@ -225,6 +219,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.GetTaskProto().GetType() { case datapb.CompactionType_Level0DeleteCompaction: