]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: cli/server: speed up proxy/server purge via the CLI
authorWilly Tarreau <w@1wt.eu>
Thu, 22 Oct 2026 13:52:29 +0000 (15:52 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 22 Oct 2026 13:58:53 +0000 (15:58 +0200)
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.

src/proxy.c
src/server.c

index 00d8925ab238040364960b782264dc56df7eb893..b285d2aa6fd7477a89434fba6c31c90aec8f7a0c 100644 (file)
@@ -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");
index 4b5d2a2012c0a1b390d7c042c0f1303e8f157a27..4775e41865c7a7971a75258fcbc43f176eceb518 100644 (file)
@@ -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);
        }