From: Aurelien DARRAGON Date: Thu, 15 Oct 2026 10:32:07 +0000 (+0200) Subject: BUG/MEDIUM: stats-file: shm-stats-file be counters not working anymore X-Git-Tag: v3.5-dev10~194 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=5c1a2975dfe92490f8bdfa8fb5d684af7aba0493;p=haproxy.git BUG/MEDIUM: stats-file: shm-stats-file be counters not working anymore As described in GH #3527, a weird behavior affects backend shared counters where haproxy would restore stats inconsistently. In fact, the described behavior happens because the stats file preloading mechanism is broken for backend objects since 5495c88 ("MEDIUM: counters: Dynamically allocate per-thread group counters") because we checked for the frontend shared map (allocated once per process) instead of the backend one for backend objects, and the frontend map is only allocated for frontends or hybrid proxies, and not backends. This caused the preloading to abort. We fix by checking the relevant backend oriented map instead. It should be backported to 3.4. Thanks to GH user @ssavant2 for his detailed report and patch feedback. --- diff --git a/src/stats-file.c b/src/stats-file.c index 761f0d2cc..07524f336 100644 --- a/src/stats-file.c +++ b/src/stats-file.c @@ -813,7 +813,7 @@ static void shm_stats_file_preload(void) } else if (curr_obj->type == SHM_STATS_FILE_OBJECT_TYPE_BE) { if (!px->be_counters.shared.tg) px->be_counters.shared.tg = calloc(global.nbtgroups, sizeof(*px->be_counters.shared.tg)); - if (px->fe_counters.shared.tg == NULL) + if (px->be_counters.shared.tg == NULL) goto release; px->be_counters.shared.tg[obj_tgid - 1] = &curr_obj->data.be; } else