Re: [PATCH] [CRITICAL] fix server state tracking: it was O(n!) instead of O(n)

From: Willy Tarreau <w#1wt.eu>
Date: Wed, 4 Feb 2009 22:38:41 +0100


Hi Krzysztof,

On Fri, Jan 30, 2009 at 01:38:38AM +0100, Krzysztof Piotr Oledzki wrote:
> >From 9bb0f6085163991924d99b7c7ff8000ade0ce0b6 Mon Sep 17 00:00:00 2001
> From: Krzysztof Piotr Oledzki <ole#ans.pl>
> Date: Fri, 30 Jan 2009 00:52:49 +0100
> Subject: [CRITICAL] fix server state tracking: it was O(n!) instead of O(n)
>
> Using the wrong operator (&& instead of &) causes DOWN->UP
> transition to take longer than it should and to produce a lot of
> redundant logs. With typical "track" usage (1-6 tracking servers) it
> shouldn't make a big difference but for heavily tracked servers
> this bug leads to hang with 100% CPU usage and extremely big
> log spam.

Wow good catch!

I'm used to sometimes check for common mistakes such as this one but I failed to detect it. Generally, to catch such errors, the following regex is enough :

  $ git grep '&&[[:space:]]*[A-Z]'

Another one I run from time to time to catch occurrences of "x &= !FLAG" :

  $ git grep '&=[[:space:]]*!'

I'm applying this one to all 3 trees.

Thanks!
Willy Received on 2009/02/04 22:38

This archive was generated by hypermail 2.2.0 : 2009/02/04 22:45 CET