]> git.kaiwu.me - haproxy.git/commitdiff
[BUG] Don't increment server connections too much + fix retries
authorKrzysztof Piotr Oledzki <ole@ans.pl>
Mon, 4 Feb 2008 01:10:09 +0000 (02:10 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 8 Mar 2008 20:58:03 +0000 (21:58 +0100)
Commit 98937b875798e10fac671d109355cde29d2a411a while fixing
one bug introduced another one. With "retries 4" and
"option redispatch" haproxy tries to connect 4 times to
one server server and 1 time to a second one. However
logs showed 5 connections to the first server (the
last one was counted twice) and 2 to the second.

This patch also fixes srv->retries and be->retries increments.

Now I get: 3 retries and 1 error in a first server (4 cum_sess)
and 1 error in a second server (1 cum_sess) with:
 retries 4
 option redispatch

and: 4 retries and 1 error (5 cum_sess) with:
 retries 4

So, the number of connections effectively served by a server is:
 srv->cum_sess - srv->failed_conns - srv->retries

(cherry picked from commit 626a19b66f769a87e7c995267ccedf14149e03b3)

src/backend.c
src/proto_http.c

index e757acc5408500e24618720997ed649719ecdaa4..88db588830896183ae1133ca988658cc0bf7aaad 100644 (file)
@@ -1347,17 +1347,12 @@ int srv_count_retry_down(struct session *t, int conn_err)
 {
        /* we are in front of a retryable error */
        t->conn_retries--;
-       if (t->srv)
-               t->srv->retries++;
-       t->be->retries++;
 
        if (t->conn_retries < 0) {
                /* if not retryable anymore, let's abort */
                tv_eternity(&t->req->cex);
                srv_close_with_err(t, conn_err, SN_FINST_C,
                                   503, error_message(t, HTTP_ERR_503));
-               if (t->srv)
-                       t->srv->cum_sess++;
                if (t->srv)
                        t->srv->failed_conns++;
                t->be->failed_conns++;
index db37035d77ef464837e3b6725bf10da805d4df6f..c01c90aab76e632ab01b9a92f1fcfc03fe8fd740 100644 (file)
@@ -2507,8 +2507,6 @@ int process_srv(struct session *t)
                                if (may_dequeue_tasks(t->srv, t->be))
                                        task_wakeup(t->srv->queue_mgt);
 
-                               if (t->srv)
-                                       t->srv->cum_sess++;
                                if (t->srv)
                                        t->srv->failed_conns++;
                                t->be->redispatches++;
@@ -2520,6 +2518,10 @@ int process_srv(struct session *t)
                                /* first, get a connection */
                                if (srv_redispatch_connect(t))
                                        return t->srv_state != SV_STCONN;
+                       } else {
+                               if (t->srv)
+                                       t->srv->retries++;
+                               t->be->retries++;
                        }
 
                        do {