Repository navigation
mod_proxy_hcheck: don't grow memory when a worker's health check changes - #1133
Conversation
…ges. Each change of a worker's health check method or URI through the balancer-manager rebuilt its pre-formatted request in the module's pool, never freeing the previous one until the next restart. Keep the request in a pool of the health check worker's own, cleared when the request is rebuilt; no check of the worker runs then (the watchdog starts the next one only once the previous one is done). * modules/proxy/mod_proxy_hcheck.c: (wctx_t): Add req_pool. (create_hcheck_req): Clear and use it, rather than taking a pool. (hc_get_hcworker): Create it. * test/modules/proxy/test_09_hcheck_log_uri.py: (TestHcheckMethodChange): New test, the new method is used after each change through the balancer-manager. * changes-entries/proxy-hcheck-req-pool.txt: New.
|
I looked into that but the fix was worse than the initial issue. Every hcheck worker now gets its own subpool, which is at least 8KB each because of APR's MIN_ALLOC. That includes TCP, CPING, ... workers, and even workers that are never changed. The leak being fixed grows by ~100 bytes per balancer-manager change, so most configs will use more memory with this patch than without it. The better fix may be to create wctx->req_pool only the first time a rebuild happens, in the "Updating hc worker" path. I haven't looked into that. So -1 for it as-is. |
|
Done as suggested: the request is now rebuilt in a pool created at the worker's first change only (then cleared at the next ones), and built in |
…nge only. A pool costs at least 8KB, for each health check worker while most never change. Build the initial request in the module's pool as before, and create the worker's request pool when its method or URI first changes, clearing it at the next changes. * modules/proxy/mod_proxy_hcheck.c: (wctx_t): Update req_pool's comment. (create_hcheck_req): Take the pool again. (hc_get_hcworker): Create req_pool at the first change, clear it at the next ones.
8d418b0 to
e7ea277
Compare
|
Hmmm... It appears that the tests pass with or without the patch. Can you confirm? |
|
Right, the test passes without the patch, it only exercises the rebuild path (the pool created at the first change, cleared at the next ones, and the request rebuilt in it), checking that each new method is the one used, not cheking the leak itself. |
|
Oh, OK. It just seemed weird that the test didn't check for the actual failure itself, so if anything else would cause the original issue of memory growth, this test wouldn't detect it; that seemed opposite from the idea of what tests should actually be testing :) |
…ck changes mod_aptest's pool probe also tells how many bytes were taken from the main server's pool of mod_proxy_hcheck, which must not grow when a worker's health check method or URI is changed through the balancer-manager. * test/pyhttpd/mod_aptest/mod_aptest.c: (aptest_child_init_process): Mark mod_proxy_hcheck's pool when loaded. (aptest_pool_probe): Add its delta as "hcheck=". * modules/proxy/mod_proxy_hcheck.c: (sctx_t): Say that p stays first, mod_aptest reads it. * test/modules/proxy/test_14_watchdog_pools.py: (probe_all): New, every pool's delta, from probe(). (TestHcheckPools.test_proxy_14_03_hcheck_changes): New test, neither the checks nor changes of each worker's method and URI grow the pool.
|
I (well claude) can do something like your 52a80d6 for I'm adding the mod_aptest pool probe now so that you can check. |
|
@jimjag is it ok now? |
|
LGTM |
Each change of a worker's health check method or URI through the balancer-manager rebuilds its pre-formatted request (
create_hcheck_req()), so far in the module's pool (ctx->p), never freeing the previous one until the next restart.The request is now rebuilt in a pool of the health check worker's own (
wctx->req_pool, a subpool ofctx->p), created at the worker's first change only (a pool costs at least 8KB) and cleared at the next ones. No check of the worker runs at that point: the watchdog only starts the next check of a worker (wherehc_get_hcworker()rebuilds the request) once the previous one is done,worker->s->updatedbeing zero meanwhile.New tests: test_09 changes a worker's health check method through the balancer-manager a few times and checks that each new method is the one used; test_14, with mod_aptest's pool probe now also measuring mod_proxy_hcheck's own pool, checks that neither the health checks nor their changes take anything from it (it fails without the fix: 576 bytes for 8 changes).