From: Willy Tarreau Date: Thu, 22 Oct 2026 13:52:29 +0000 (+0200) Subject: MINOR: cli/server: speed up proxy/server purge via the CLI X-Git-Tag: v3.5-dev10~73 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=098503ad02fdf77637daf5067858bee96f4c0496;p=haproxy.git MINOR: cli/server: speed up proxy/server purge via the CLI The following recent commits implemented support for purging servers and backends from the CLI: 0c6d8ee23fa5 ("MEDIUM: proxy: implement purge backend") d4d8a762a0fd ("MEDIUM: server: implement "purge all servers" CLI") 410719abdc07 ("MEDIUM: server: implement "purge server" CLI") At the moment, when it is detected that it is not possible to complete the purge, a background task is scheduled to retry every second. However tests show that most of the time the operation completes almost instantly (typically less than 20ms in local tests), so it's a bit sad to wait for a full second in this case. In addition, it requires to apply a longer client timeout to the VTC than any previous test. Ideally it would be nice to use a capped exponential growth for retries, but even without going this far, a nice first approach that brings immediate benefit is to wait a very short time before the first retry, while keeping the 1-second delay for subsequent ones. It's easy to do because the code that arms the initial retry is performed in the command pasing function while the next retries are in the task itself. That's what this commit does. Now most of these operations will be performed in either 0.05s or 1.05s instead of 1s. And regtests are happy again. --- diff --git a/src/proxy.c b/src/proxy.c index 00d8925ab..b285d2aa6 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -5669,7 +5669,7 @@ static int cli_parse_purge_backend(char **args, char *payload, struct appctx *ap if (!ret) { px->flags |= PR_FL_TO_PURGE; if (!tick_isset(px->purge_task->expire)) - px->purge_task->expire = tick_add(now_ms, 1000); + px->purge_task->expire = tick_add(now_ms, 50); task_queue(px->purge_task); ha_notice("Backend '%s' flagged for deletion.\n", px->id); cli_msg(appctx, LOG_INFO, "Backend scheduled for purge.\n"); diff --git a/src/server.c b/src/server.c index 4b5d2a201..4775e4186 100644 --- a/src/server.c +++ b/src/server.c @@ -7180,7 +7180,7 @@ static int cli_parse_purge_server(char **args, char *payload, struct appctx *app srv->flags |= SRV_F_TO_PURGE; if (!tick_isset(be->purge_task->expire)) - be->purge_task->expire = tick_add(now_ms, 1000); + be->purge_task->expire = tick_add(now_ms, 50); task_queue(be->purge_task); ha_notice("Server '%s/%s' flagged for deletion.\n", be->id, srv->id); cli_msg(appctx, LOG_INFO, "Server scheduled for purge.\n"); @@ -7301,7 +7301,7 @@ static int cli_io_handler_purge_all_server(struct appctx *appctx) if (ctx->c1) { if (!tick_isset(be->purge_task->expire)) - be->purge_task->expire = tick_add(now_ms, 1000); + be->purge_task->expire = tick_add(now_ms, 50); task_queue(be->purge_task); }