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".
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",