]> git.kaiwu.me - haproxy.git/commit
DEBUG: servers: add a few checks for stress-testing idle conns
authorWilly Tarreau <w@1wt.eu>
Fri, 14 Nov 2025 15:48:16 +0000 (16:48 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 14 Nov 2025 16:00:17 +0000 (17:00 +0100)
commit4a6dec71934d4b3bccff52be0ea01e312a5bda72
treeb95ad9a3d6e042f3913f93f41fb7beb9e95cc1a7
parent675c86c4aa29410de806dcfe7abe099dc541be03
DEBUG: servers: add a few checks for stress-testing idle conns

The latest idle conns fix 9481cef948 ("BUG/MEDIUM: connection: do not
reinsert a purgeable conn in idle list") addresses a very hard-to-hit
case which manifests itself with an attempt to reuse a connection fails
because conn->mux is NULL:

  Program terminated with signal SIGSEGV, Segmentation fault.
  #0  0x0000655410b8642c in conn_backend_get (reuse_mode=4, srv=srv@entry=0x6554378a7140,
      sess=sess@entry=0x7cfe140948a0, is_safe=is_safe@entry=0,
      hash=hash@entry=910818338996668161) at src/backend.c:1390
  1390     if (conn->mux->takeover && conn->mux->takeover(conn, i, 0) == 0) {

However the condition that leads to this situation can be detected
earlier, by the presence of the connection in the toremove_list, whose
race window is much larger and easier to detect.

This patch adds a few BUG_ON_STRESS() at selected places that an detect
this condition. When built with -DDEBUG_STRESS and run under stress with
two distinct processes communicating over H2 over SSL, under a stress of
400-500k req/s, the front process usually crashes in the first 10-30s
triggering in _srv_add_idle() if the fix above is reverted (and it does
not crash with the fix).

This is mainly included to serve as an illustration of how to instrument
the code for seamless stress testing.
src/mux_h2.c
src/server.c