]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: stick-table: fix the peers overhead in proto_size
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 18 Nov 2026 10:07:58 +0000 (11:07 +0100)
committerOlivier Houchard <cognet@ci0.org>
Wed, 18 Nov 2026 15:33:22 +0000 (16:33 +0100)
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".

src/stick_table.c

index 43a3b835d8c60041fab2687e33832b0a25d54a4e..6489fbbdc03ce55f4bb83cead351f1f9329e8a1b 100644 (file)
@@ -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",