Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed May 15, 2024
1 parent 5b315aa commit e259832
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/ratelimit/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit e259832

Please sign in to comment.