Skip to main content

FORWARDED_STARTUP_PARAM_ALLOWANCE

Constant FORWARDED_STARTUP_PARAM_ALLOWANCE 

Source
pub const FORWARDED_STARTUP_PARAM_ALLOWANCE: usize = 512;
Expand description

Startup budget allowed on top of MAX_STARTUP_FRAME_SIZE for parameters a balancer appends while forwarding.

A balancer adds CONN_UUID_KEY and MZ_FORWARDED_FOR_KEY to the parameters before forwarding startup, so a frame that just fits the client budget arrives downstream larger than the client sent it. Without this allowance such a connection is accepted by the balancer and then rejected behind it, which surfaces as a proxy error with no obvious cause.

The two parameters cost at most 119 bytes: an 18-byte key with a 36-byte UUID, a 16-byte key with an address of up to 45 bytes, and a NUL after each of the four strings. The rest is headroom, so that adding a third forwarded parameter does not immediately require re-deriving this number. Going over it is caught by test_forwarded_startup_frame_fits_downstream_budget, which measures what a balancer actually puts on the wire rather than trusting this comment.