]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: stats-file: shm-stats-file be counters not working anymore
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 15 Oct 2026 10:32:07 +0000 (12:32 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Thu, 15 Oct 2026 10:32:07 +0000 (12:32 +0200)
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.

src/stats-file.c

index 761f0d2ccefe06740072c2420ba35fc49034aa5e..07524f336d6c90e31eb401a07951a905f87c26f2 100644 (file)
@@ -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