On Tue, Jul 26, 2016 at 08:44:59PM +0800, Ruoshan Huang wrote:
> Ah, I just find a problem in this snip
> 
> ```
> +                                       if ((unsigned)(txn->status - 400) <
> 100)
> +                                               stream_inc_http_err_ctr(s);
> ```
> calling `stream_inc_http_err_ctr` may cause the http_err_cnt be increased
> twice for other stick counter tracked by `http-request track-sc`. for
> example:
> 
> ```
> frontend fe
>     bind *:7001
>     stick-table type ip size 100 expire 10m store http_req_cnt,http_err_cnt
>     http-request track-sc1 src
>     http-response track-sc2 status table dummy
>     default_backend be
> 
> backend be
>     server b1 127.0.0.1:8000
> 
> backend dummy
>     stick-table type integer size 100 expire 10m store
> http_req_cnt,http_err_cnt
> ```
> the `http_err_cnt` in table `fe` will be increased twice for every 4xx
> response.

Ah crap, I didn't think about this case. And I tried to find corner cases :-(
And that just makes me think that using multiple consecutive http-response
track-sc rules will cause the same problem.

> we should only increase the err counter for the current stick counter entry.

Yes you're right. For me this one fixes it (both with http-request and
multiple http-response), is that OK for you ?

Willy

diff --git a/src/proto_http.c b/src/proto_http.c
index d2090bb..3e18a6c 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -3816,8 +3816,16 @@ resume_execution:
                                         * but here we're tracking after this 
ought to have been done so we have
                                         * to do it on purpose.
                                         */
-                                       if ((unsigned)(txn->status - 400) < 100)
-                                               stream_inc_http_err_ctr(s);
+                                       if ((unsigned)(txn->status - 400) < 
100) {
+                                               ptr = stktable_data_ptr(t, ts, 
STKTABLE_DT_HTTP_ERR_CNT);
+                                               if (ptr)
+                                                       stktable_data_cast(ptr, 
http_err_cnt)++;
+
+                                               ptr = stktable_data_ptr(t, ts, 
STKTABLE_DT_HTTP_ERR_RATE);
+                                               if (ptr)
+                                                       
update_freq_ctr_period(&stktable_data_cast(ptr, http_err_rate),
+                                                                              
t->data_arg[STKTABLE_DT_HTTP_ERR_RATE].u, 1);
+                                       }
                                }
                        }
                        break;


Reply via email to