From 078c79a0090f7161658607fe495cf67d0ed7fc8f Mon Sep 17 00:00:00 2001 From: willy tarreau Date: Sat, 13 May 2006 12:23:58 +0200 Subject: [PATCH] [MINOR] make logs more accurate about expiration and close during queue. --- doc/haproxy-en.txt | 11 +++++++ doc/haproxy-fr.txt | 14 ++++++++ haproxy.c | 79 ++++++++++++++++++++++++++++++++++++---------- 3 files changed, 87 insertions(+), 17 deletions(-) diff --git a/doc/haproxy-en.txt b/doc/haproxy-en.txt index 59cba6869..45b70aeb8 100644 --- a/doc/haproxy-en.txt +++ b/doc/haproxy-en.txt @@ -1589,6 +1589,17 @@ The most common termination flags combinations are indicated here. by too large TCP MSS values for PPPoE networks which cannot transport full-sized packets. + CH The client aborted while waiting for the server to start responding. + It might be the server taking too long to respond or the client + clicking the 'Stop' button too fast. + + CQ The client aborted while its session was queued, waiting for a server + with enough empty slots to accept it. It might be that either all the + servers were saturated or the assigned server taking too long to + respond. + + sQ The session spent too much time in queue and has been expired. + SH The server aborted before sending its full headers, or it crashed. sH The server failed to reply during the srvtimeout delay, which diff --git a/doc/haproxy-fr.txt b/doc/haproxy-fr.txt index 4702c7f67..8bb25a1c5 100644 --- a/doc/haproxy-fr.txt +++ b/doc/haproxy-fr.txt @@ -1642,6 +1642,20 @@ Les combinaisons d'indicateurs les plus fr pour des réseaux PPPoE sur ADSL qui ne peuvent pas transporter des paquets entiers. + CH Le client a abandonné alors qu'il attendait un début de réponse de la + part du serveur. Cela peut être causé par le serveur qui mettait trop + de temps à répondre, ou par un client cliquant précipitamment sur le + bouton 'Stop'. + + CQ Le client a abandonné alors que sa session était mise en file + d'attente pour obtenir un serveur avec suffisamment de connexions + libres pour l'accepter. Cela signifie soit que l'ensemble des + serveurs étaient saturés, soit que le serveur assigné a mis trop de + temps à répondre. + + sQ La session a attendu trop longtemps en file d'attente et a été + expirée. + SH Le serveur a aborté brutalement alors qu'il devait envoyer ses en-têtes. En général, cela indique qu'il a crashé. diff --git a/haproxy.c b/haproxy.c index 722ff0441..e51ae32f3 100644 --- a/haproxy.c +++ b/haproxy.c @@ -386,6 +386,7 @@ int strlcpy2(char *dst, const char *src, int size) { #define SN_FINST_H 0x00003000 /* session ended during server headers */ #define SN_FINST_D 0x00004000 /* session ended during data phase */ #define SN_FINST_L 0x00005000 /* session ended while pushing last data to client */ +#define SN_FINST_Q 0x00006000 /* session ended while waiting in queue for a server slot */ #define SN_FINST_MASK 0x00007000 /* mask to get only final session state flags */ #define SN_FINST_SHIFT 12 /* bit shift */ @@ -809,7 +810,7 @@ const char *monthname[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; const char sess_term_cond[8] = "-cCsSPRI"; /* normal, CliTo, CliErr, SrvTo, SrvErr, PxErr, Resource, Internal */ -const char sess_fin_state[8] = "-RCHDL67"; /* cliRequest, srvConnect, srvHeader, Data, Last, unknown */ +const char sess_fin_state[8] = "-RCHDLQ7"; /* cliRequest, srvConnect, srvHeader, Data, Last, Queue, unknown */ const char sess_cookie[4] = "NIDV"; /* No cookie, Invalid cookie, cookie for a Down server, Valid cookie */ const char sess_set_cookie[8] = "N1I3PD5R"; /* No set-cookie, unknown, Set-Cookie Inserted, unknown, Set-cookie seen and left unchanged (passive), Set-cookie Deleted, @@ -4309,8 +4310,14 @@ int process_cli(struct session *t) { t->cli_state = CL_STCLOSE; if (!(t->flags & SN_ERR_MASK)) t->flags |= SN_ERR_CLICL; - if (!(t->flags & SN_FINST_MASK)) - t->flags |= SN_FINST_D; + if (!(t->flags & SN_FINST_MASK)) { + if (t->pend_pos) + t->flags |= SN_FINST_Q; + else if (s == SV_STCONN) + t->flags |= SN_FINST_C; + else + t->flags |= SN_FINST_D; + } return 1; } /* last read, or end of server write */ @@ -4343,8 +4350,14 @@ int process_cli(struct session *t) { t->cli_state = CL_STSHUTR; if (!(t->flags & SN_ERR_MASK)) t->flags |= SN_ERR_CLITO; - if (!(t->flags & SN_FINST_MASK)) - t->flags |= SN_FINST_D; + if (!(t->flags & SN_FINST_MASK)) { + if (t->pend_pos) + t->flags |= SN_FINST_Q; + else if (s == SV_STCONN) + t->flags |= SN_FINST_C; + else + t->flags |= SN_FINST_D; + } return 1; } /* write timeout */ @@ -4361,8 +4374,14 @@ int process_cli(struct session *t) { t->cli_state = CL_STSHUTW; if (!(t->flags & SN_ERR_MASK)) t->flags |= SN_ERR_CLITO; - if (!(t->flags & SN_FINST_MASK)) - t->flags |= SN_FINST_D; + if (!(t->flags & SN_FINST_MASK)) { + if (t->pend_pos) + t->flags |= SN_FINST_Q; + else if (s == SV_STCONN) + t->flags |= SN_FINST_C; + else + t->flags |= SN_FINST_D; + } return 1; } @@ -4420,8 +4439,14 @@ int process_cli(struct session *t) { t->cli_state = CL_STCLOSE; if (!(t->flags & SN_ERR_MASK)) t->flags |= SN_ERR_CLICL; - if (!(t->flags & SN_FINST_MASK)) - t->flags |= SN_FINST_D; + if (!(t->flags & SN_FINST_MASK)) { + if (t->pend_pos) + t->flags |= SN_FINST_Q; + else if (s == SV_STCONN) + t->flags |= SN_FINST_C; + else + t->flags |= SN_FINST_D; + } return 1; } else if ((s == SV_STSHUTR || s == SV_STCLOSE) && (rep->l == 0)) { @@ -4436,8 +4461,14 @@ int process_cli(struct session *t) { t->cli_state = CL_STCLOSE; if (!(t->flags & SN_ERR_MASK)) t->flags |= SN_ERR_CLITO; - if (!(t->flags & SN_FINST_MASK)) - t->flags |= SN_FINST_D; + if (!(t->flags & SN_FINST_MASK)) { + if (t->pend_pos) + t->flags |= SN_FINST_Q; + else if (s == SV_STCONN) + t->flags |= SN_FINST_C; + else + t->flags |= SN_FINST_D; + } return 1; } else if ((rep->l == 0) || @@ -4469,8 +4500,14 @@ int process_cli(struct session *t) { t->cli_state = CL_STCLOSE; if (!(t->flags & SN_ERR_MASK)) t->flags |= SN_ERR_CLICL; - if (!(t->flags & SN_FINST_MASK)) - t->flags |= SN_FINST_D; + if (!(t->flags & SN_FINST_MASK)) { + if (t->pend_pos) + t->flags |= SN_FINST_Q; + else if (s == SV_STCONN) + t->flags |= SN_FINST_C; + else + t->flags |= SN_FINST_D; + } return 1; } else if (t->res_cr == RES_NULL || s == SV_STSHUTW || s == SV_STCLOSE) { @@ -4485,8 +4522,14 @@ int process_cli(struct session *t) { t->cli_state = CL_STCLOSE; if (!(t->flags & SN_ERR_MASK)) t->flags |= SN_ERR_CLITO; - if (!(t->flags & SN_FINST_MASK)) - t->flags |= SN_FINST_D; + if (!(t->flags & SN_FINST_MASK)) { + if (t->pend_pos) + t->flags |= SN_FINST_Q; + else if (s == SV_STCONN) + t->flags |= SN_FINST_C; + else + t->flags |= SN_FINST_D; + } return 1; } else if (req->l >= req->rlim - req->data) { @@ -4706,7 +4749,8 @@ int process_srv(struct session *t) { c == CL_STSHUTW || (c == CL_STSHUTR && t->req->l == 0)) { /* give up */ tv_eternity(&t->cnexpire); - srv_close_with_err(t, SN_ERR_CLICL, SN_FINST_C, 0, 0, NULL); + t->logs.t_queue = tv_diff(&t->logs.tv_accept, &now); + srv_close_with_err(t, SN_ERR_CLICL, t->pend_pos ? SN_FINST_Q : SN_FINST_C, 0, 0, NULL); return 1; } @@ -4722,7 +4766,8 @@ int process_srv(struct session *t) { else { /* we've been waiting too long here */ tv_eternity(&t->cnexpire); - srv_close_with_err(t, SN_ERR_SRVTO, SN_FINST_C, + t->logs.t_queue = tv_diff(&t->logs.tv_accept, &now); + srv_close_with_err(t, SN_ERR_SRVTO, SN_FINST_Q, 503, t->proxy->errmsg.len503, t->proxy->errmsg.msg503); return 1; }