From e2598321312caa3579bdf7b2ab35396c6bd5e595 Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Tue, 14 May 2024 14:53:57 +0800 Subject: [PATCH] address comments Signed-off-by: Ryan Leung --- pkg/ratelimit/runner.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/ratelimit/runner.go b/pkg/ratelimit/runner.go index 0245a5a1d0f2..a3f6a5e4a17f 100644 --- a/pkg/ratelimit/runner.go +++ b/pkg/ratelimit/runner.go @@ -196,11 +196,13 @@ func (cr *ConcurrentRunner) RunTask(ctx context.Context, name string, f func(con opt(task) } - cr.processPendingTasks() cr.pendingMu.Lock() - defer cr.pendingMu.Unlock() + defer func() { + cr.pendingMu.Unlock() + cr.processPendingTasks() + }() if task.priority >= constant.High { - // We use the max task number to prevent the OOM issue. + // We use the max task number to limit the memory usage. // It occupies around 1.5GB memory when there is 20000000 pending task. if len(cr.pendingHighPriorityTasks) > maxHighPriorityTaskNum { RunnerFailedTasks.WithLabelValues(cr.name, task.name).Inc()