From c6c8cd92a1ef8ac360f51ce5c9d0a7b784c64d65 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 4 Aug 2021 19:35:13 +0200 Subject: [PATCH] BUG/MINOR: server: update last_change on maint->ready transitions too Nenad noticed that when leaving maintenance, the servers' last_change field was not updated. This is visible in the Status column of the stats page in front of the state, as the cumuled time spent in the current state is wrong, it starts from the last transition (typically ready->maint). In addition, the backend's state was not updated either, because the down transition is performed by set_backend_down() which also emits a log, and it is this function which was extended to update the backend's last_change, but it's not called for down->up transitions so that was not done. The most visible (and unpleasant) effect of this bug is that it affects slowstart so such a server could immediately restart with a significant load ratio. This should likely be backported to all stable releases. (cherry picked from commit d332f1396b101f3f03e9fef405d42f03fc3647b6) Signed-off-by: Willy Tarreau (cherry picked from commit f79c4cf84967ffcc96e375c48afcb472ad246876) Signed-off-by: Willy Tarreau --- src/server.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/server.c b/src/server.c index da193db..911085e 100644 --- a/src/server.c +++ b/src/server.c @@ -5087,6 +5087,7 @@ static void srv_update_status(struct server *s) s->next_state = SRV_ST_STOPPING; } else { + s->last_change = now.tv_sec; s->next_state = SRV_ST_STARTING; if (s->slowstart > 0) { if (s->warmup) @@ -5146,6 +5147,8 @@ static void srv_update_status(struct server *s) if (prev_srv_count && s->proxy->srv_bck == 0 && s->proxy->srv_act == 0) set_backend_down(s->proxy); + else if (!prev_srv_count && (s->proxy->srv_bck || s->proxy->srv_act)) + s->proxy->last_change = now.tv_sec; /* If the server is set with "on-marked-up shutdown-backup-sessions", * and it's not a backup server and its effective weight is > 0, -- 1.7.10.4