]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: mworker/cli: fix show proc pagination losing entries on resume
authorAlexander Stephan <alexander.stephan@sap.com>
Thu, 19 Feb 2026 11:31:45 +0000 (11:31 +0000)
committerWilliam Lallemand <wlallemand@haproxy.com>
Thu, 19 Mar 2026 13:46:15 +0000 (14:46 +0100)
commit10e78d9246d7d32d8c4d2943ae33b10475205434
treea899ea0ae12566852d6d356e27f459bfe2146baf
parent4e937e03919fe9fea6c84c47f85dcb5847e7a070
BUG/MINOR: mworker/cli: fix show proc pagination losing entries on resume

After commit 594408cd612b5 ("BUG/MINOR: mworker/cli: fix show proc
pagination using reload counter"), the old-workers pagination stores
ctx->next_reload = child->reloads on flush failure, then skips entries
with child->reloads >= ctx->next_reload on resume.

The >= comparison is direction-dependent: it assumes the list is in
descending reload order (newest first). On current master, proc_list
is in ascending order (oldest first) because mworker_env_to_proc_list()
appends deserialized entries before mworker_prepare_master() appends
the new worker. This means the skip logic is inverted and can miss
entries or loop incorrectly depending on the version.

We fix this by renaming the context field to resume_reload and changing its
semantics: it now tracks the reload count of the last *successfully
flushed* row rather than the failed one. On flush failure, resume_reload
is left unchanged so the failed row is replayed on the next call. On
resume, entries are skipped by walking the list until the marker entry is
found (exact == match), which works regardless of list direction.

Additionally, we have to handle the unlikely case where the marker entry
is deleted from proc_list between handler calls (e.g. the process exits and
SIGCHLD processing removes it). Detect this by tracking the previous
LEAVING entry's reload count during the skip phase: if two consecutive
entries straddle the skip value (one > skip, the other < skip), the
deleted entry's former position has been crossed, so skipping stops and
the current entry is emitted.

This should be backported to all stable branches. On branches where
proc_list is in descending order (2.9, 3.0), the fix applies the
same way since the skip logic is now direction-agnostic.
src/mworker.c