haproxy/examples
Aurelien DARRAGON 4cc2714ae2 EXAMPLES: fix race condition in lua mailers script
Christopher reported a rare race condition involving 'healthcheckmail.vtc'

The regtest would randomly FAIL with this kind of error:

    **   S1    === expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server b...
    **** S1    EXPECT MATCH ~ "[^:\[ ]\[581669\]: Health check for server be1/srv1 failed.+check duration: [[:digit:]]+ms.+status: 0/1 DOWN."
    **   S1    === recv info
    **** S1    syslog|<25>May 11 15:38:46 haproxy[581669]: Server be1/srv1 is DOWN. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
    **** S1    syslog|<24>May 11 15:38:46 haproxy[581669]: backend be1 has no server available!

It turns out that this it due to the recent commit 7963fb5 ("REGTESTS: use
lua mailer script for mailers tests") in which we tell the regtest to use
the new lua mailers instead of the legacy mailers API.

However, in the lua mailers script, due to the event subscriptions being
performed from a lua task, it is possible that the subscription may be
delayed during startup. Indeed lua tasks relie on the scheduler which runs
tasks with no ordering guarantees. Thus early tasks, including server
checks which are used in the regtest are competing during startup.

As such, we may end up with some events that are generated right before
the lua mailers script starts subscribing to events (because the lua task
is scheduled but started yet), resulting in events loss from lua point of
view.

To fix this and to make lua mailers more reliable during startup, we now
perform the events subscription from an init function instead of an
asynchronous task. (The init function is called synchronously during
haproxy post_init, and exclusively runs before the scheduler starts)

This should be enough to prevent healthcheckmail.vtc from randomly failing
2023-05-12 09:45:30 +02:00
..
errorfiles MINOR: fix typos in the examples files 2018-11-18 22:24:51 +01:00
lua EXAMPLES: fix race condition in lua mailers script 2023-05-12 09:45:30 +02:00
basic-config-edge.cfg EXAMPLES: add a "basic-config-edge" example config 2021-05-12 17:50:16 +02:00
content-sw-sample.cfg CLEANUP: examples: fix the example file content-sw-sample.cfg 2015-10-13 16:47:16 +02:00
haproxy.init DOC: remove last occurrences of "HA-Proxy" syntax 2021-05-09 06:29:40 +02:00
option-http_proxy.cfg MEDIUM: proxy: remove long-broken 'option http_proxy' 2021-07-18 19:35:32 +02:00
quick-test.cfg EXAMPLES: add a trivial config for quick testing 2021-05-12 17:54:56 +02:00
socks4.cfg MEDIUM: connection: Upstream SOCKS4 proxy support 2019-05-31 17:24:06 +02:00
transparent_proxy.cfg CLEANUP: assorted typo fixes in the code and comments 2020-06-26 11:27:28 +02:00
wurfl-example.cfg CLEANUP: assorted typo fixes in the code and comments 2020-06-26 11:27:28 +02:00