]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: checks: Stop scheduling healthchecks during stopping stage
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 16 May 2023 16:07:51 +0000 (18:07 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 17 May 2023 12:57:10 +0000 (14:57 +0200)
When the process is stopping, the health-checks are suspended. However the
task is still periodically woken up for nothing. If there is a huge number
of health-checks and if they are woken up in same time, it may lead to a
noticeable CPU consumption for no reason.

To avoid this extra CPU cost, we stop to schedule the health-check tasks
when the proxy is disabled or stopped.

This patch should partially solve the issue #2145.

src/check.c

index a440185daaa331256abb9df8534797fdc17f12ce..786c1c61cca1a86846eb1f7d901ee61b75a40c6a 100644 (file)
@@ -1327,8 +1327,13 @@ struct task *process_chk_conn(struct task *t, void *context, unsigned int state)
        }
 
  reschedule:
-       while (tick_is_expired(t->expire, now_ms))
-               t->expire = tick_add(t->expire, MS_TO_TICKS(check->inter));
+       if (proxy->flags & (PR_FL_DISABLED|PR_FL_STOPPED))
+               t->expire = TICK_ETERNITY;
+       else {
+               while (tick_is_expired(t->expire, now_ms))
+                       t->expire = tick_add(t->expire, MS_TO_TICKS(check->inter));
+       }
+
  out_unlock:
        if (check->server)
                HA_SPIN_UNLOCK(SERVER_LOCK, &check->server->lock);