]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: log: make "show startup-log" use a ring buffer instead
authorWilly Tarreau <w@1wt.eu>
Fri, 15 Nov 2019 14:16:57 +0000 (15:16 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 15 Nov 2019 14:50:16 +0000 (15:50 +0100)
commit869efd5eeb8e715668c6260d468fdba77f347fb1
treeb51d8d6a7e9237344e81be919f86fb3c2c6ceb8a
parentfcf94981e485aa17ccc8b3371e0a4cb9724bda8b
BUG/MINOR: log: make "show startup-log" use a ring buffer instead

The copy of the startup logs used to rely on a re-allocated memory area
on the fly, that would attempt to be delivered at once over the CLI. But
if it's too large (too many warnings) it will take time to start up, and
may not even show up on the CLI as it doesn't fit in a buffer.

The ring buffer infrastructure solves all this with no more code, let's
switch to this instead. It simply requires a parsing function to attach
the ring via ring_attach_cli() and all the rest is automatically handled.

Initially this was imagined as a code cleanup, until a test with a config
involving 100k backends and just one occurrence of
"load-server-state-from-file global" in the defaults section took approx
20 minutes to parse due to the O(N^2) cost of concatenating the warnings
resulting in ~1 TB of data to be copied, while it took only 0.57s with
the ring.

Ideally this patch should be backported to 2.0 and 1.9, though it relies
on the ring infrastructure which will then also need to be backported.
Configs able to trigger the bug are uncommon, so another workaround for
older versions without backporting the rings would consist in simply
limiting the size of the error message in print_message() to something
always printable, which will only return the first errors.
include/types/log.h
src/log.c