From: Willy Tarreau Date: Thu, 17 Aug 2023 14:09:05 +0000 (+0200) Subject: MINOR: checks: start the checks in sleeping state X-Git-Tag: v2.9-dev5~85 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7163f95b43476ccddbd07d37148e0d040e353dcf;p=thirdparty%2Fhaproxy.git MINOR: checks: start the checks in sleeping state The CHK_ST_SLEEPING state was introduced by commit d114f4a68 ("MEDIUM: checks: spread the checks load over random threads") to indicate that a check was not currently bound to a thread and that it could easily be migrated to any other thread. However it did not start the checks in this state, meaning that they were not redispatchable on startup. Sometimes under heavy load (e.g. when using SSL checks with OpenSSL 3.0) the cost of setting up new connections is so high that some threads may experience connection timeouts on startup. In this case it's better if they can transfer their excess load to other idle threads. By just marking the check as sleeping upon startup, we can do this and significantly reduce the number of failed initial checks. --- diff --git a/include/haproxy/check-t.h b/include/haproxy/check-t.h index 5b80189ee2..26290b44bc 100644 --- a/include/haproxy/check-t.h +++ b/include/haproxy/check-t.h @@ -56,7 +56,7 @@ enum chk_result { #define CHK_ST_OUT_ALLOC 0x0080 /* check blocked waiting for output buffer allocation */ #define CHK_ST_CLOSE_CONN 0x0100 /* check is waiting that the connection gets closed */ #define CHK_ST_PURGE 0x0200 /* check must be freed */ -#define CHK_ST_SLEEPING 0x0400 /* check was sleeping */ +#define CHK_ST_SLEEPING 0x0400 /* check was sleeping, i.e. not currently bound to a thread */ #define CHK_ST_FASTINTER 0x0800 /* force fastinter check */ /* check status */ diff --git a/src/check.c b/src/check.c index 7359c2574d..fce152a96e 100644 --- a/src/check.c +++ b/src/check.c @@ -1754,7 +1754,7 @@ int init_srv_check(struct server *srv) ret |= ERR_ALERT | ERR_ABORT; goto out; } - srv->check.state |= CHK_ST_CONFIGURED | CHK_ST_ENABLED; + srv->check.state |= CHK_ST_CONFIGURED | CHK_ST_ENABLED | CHK_ST_SLEEPING; srv_take(srv); /* Only increment maxsock for servers from the configuration. Dynamic @@ -1817,7 +1817,7 @@ int init_srv_agent_check(struct server *srv) if (!srv->agent.inter) srv->agent.inter = srv->check.inter; - srv->agent.state |= CHK_ST_CONFIGURED | CHK_ST_ENABLED | CHK_ST_AGENT; + srv->agent.state |= CHK_ST_CONFIGURED | CHK_ST_ENABLED | CHK_ST_SLEEPING | CHK_ST_AGENT; srv_take(srv); /* Only increment maxsock for servers from the configuration. Dynamic