]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: listener: mark the thread as not stuck inside the loop
authorWilly Tarreau <w@1wt.eu>
Fri, 1 May 2020 07:51:11 +0000 (09:51 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 May 2020 09:41:36 +0000 (11:41 +0200)
We tried hard to make sure we report threads as not stuck at various
crucial places, but one of them is special, it's the listener_accept()
function. The reason it is special is because it will loop a certain
number of times (default: 64) accepting incoming connections, allocating
resources, dispatching them to other threads or running L4 rules on them,
and while all of this is supposed to be extremely fast, when the machine
slows down or runs low on memory, the expectedly small delays in malloc()
caused by contention with other threads can quickly accumulate and suddenly
become critical to the point of triggering the watchdog. Furthermore, it
is technically possible to trigger this by pure configuration by setting
a huge tune.maxaccept value, which should not be possible.

Given that each operation isn't related to the same task but to a different
one each time, it is appropriate to mark the thread as not stuck each time
it accepts new work that possibly gets dispatched to other threads which
execute it.

This looks like this could be a good reason for the issue reported in
issue #388.

This fix must be backported to 2.0.

src/listener.c

index ef7567e5e9b1dd6321fd58a00491454f38d6610d..829dc99b74efe6dfb29d0405e31f3fe154597731 100644 (file)
@@ -1036,6 +1036,7 @@ void listener_accept(int fd)
                }
 #endif
 
+               ti->flags &= ~TI_FL_STUCK; // this thread is still running
        } /* end of for (max_accept--) */
 
  end: