On Tue, Mar 23, 2021 at 08:08:16AM +0100, Willy Tarreau wrote:
> Hi guys,
> 
> On Mon, Mar 22, 2021 at 10:08:01PM +0000, Bren wrote:
> > > I have upgraded to haproxy 2.2.11 today and it seems like my stick table 
> > > counter is not working anymore.
> > 
> > I was going to upgrade to 2.2.11 soon so I tested this quick and can 
> > confirm that counters no longer decrement over time. Tested this using the 
> > haproxy:2.2.11 Docker image and a standard stick table:
> > 
> > fe-test
> >   http-request track-sc0 src table be-test
> > 
> > be-test
> >   stick-table type ipv6 size 1m expire 24h store http_req_rate(2s)
> 
> I'll have a look at it. I fixed a problem affecting the counters
> that was occasionally causing livelocks in multi-threaded
> environments and causing the counters to be randomly reset when
> switching to the next second, I could confirm that it did address
> the problem for me (i.e. no more zeroes nor livelocks) but I have not
> seen this corner case yet. I'll keep you updated.

I understand now. My logic for the periods was flawed because I assumed
that now_ms only represented the millisecond within the current second
while it contains the current tick. And given that my test was run with
sub-second period to make sure not to mess up on this one, I failed the
other ones that are >1s :-(

I'll introduce a global_now_ms for the monotonic tick counter, it will
be easier and safer than having to perform the operation at various
call places.

In the mean time, if anyone has a good idea how to write a regtest for
freq_ctrs, I'd be very interested in smart suggestions. Last time I
was quite frustrated not being able to test these ones because they're
too timing-dependent for an automated test and ended up using obviously
incomplete tests :-/

Thanks,
Willy

Reply via email to