From: Olivier Houchard Date: Wed, 18 Nov 2026 10:07:58 +0000 (+0100) Subject: BUG/MEDIUM: stick-table: fix the peers overhead in proto_size X-Git-Tag: v3.5-dev13~2 X-Git-Url: https://git.kaiwu.me/web/%22data:,/doc/static/%7B@url%7D?a=commitdiff_plain;h=854701a3395519ef3d86c51f508698b7b582b0e8;p=haproxy.git BUG/MEDIUM: stick-table: fix the peers overhead in proto_size proto_size accounts for 11 bytes of encapsulation, but update messages are built in place with the header, room for the encoded length, the update id and the expiration date, plus the string key length. String keys trimmed to fit the estimate, such as a large header tracked on a table whose len is close to or above bufsize, thus never fit an update message, and neither do binary keys of a table accepted at the limit by the config check. Since commit ef4405d67 ("BUG/MEDIUM: peers: bound stick-table update messages") this does not overflow the trash buffer anymore, but the peer session is closed and reopened in loop and the resync never completes. See GitHub issue #3576. Let's count the real overhead. This was brought by commit 858263591 ("MINOR: stick-table: calculate the on-wire size of each key") and must be backported wherever it was, along with previous commit "MINOR: peers: move message length constants to peers-t.h". --- diff --git a/src/stick_table.c b/src/stick_table.c index 43a3b835d..6489fbbdc 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -1696,12 +1696,14 @@ int parse_stick_table(const char *file, int linenum, char **args, goto out; } - /* the key is sent as-is for most types (string is trimmed), and 11 - * extra bytes of encapsulation are added when sending (measured). + /* the key is sent as-is for most types (string is trimmed and has its + * length encoded), after a header, update id and expiration date. */ - t->proto_size += 11; + t->proto_size += PEER_MSG_HEADER_LEN + PEER_MSG_ENC_LENGTH_MAXLEN + 2 * sizeof(uint32_t); if (t->type != SMP_T_STR) t->proto_size += t->key_size; + else + t->proto_size += PEER_MSG_ENC_LENGTH_MAXLEN; if (t->proto_size > global.tune.bufsize) { ha_alert("parsing [%s:%d] : %s: too large key+data (%d bytes on wire) for bufsize (%u). Reduce key len, reduce stored data, or increase tune.bufsize.\n",