]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: peers: apply a random reconnection timeout
authorWilly Tarreau <w@1wt.eu>
Wed, 20 May 2015 08:39:04 +0000 (10:39 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 20 May 2015 08:49:07 +0000 (10:49 +0200)
commitb4e34da692d8a7f6837ad16b3389f5830dbc11d2
tree3ceac204aaafcc201737dbcdede488d830158a65
parent1ede1daab60cae75db6d7d7742a11798bf17aa1c
BUG/MEDIUM: peers: apply a random reconnection timeout

Commit 9ff95bb ("BUG/MEDIUM: peers: correctly configure the client timeout")
uncovered an old bug in the peers : upon disconnect, we reconnect immediately.
This sometimes results in both ends to do the same thing in parallel causing
a loop of connect/accept/close/close that can last several seconds. The risk
of occurrence of the trouble increases with latency, and is emphasized by the
fact that idle connections are now frequently recycled (after 5s of idle).

In order to avoid this we must apply a random delay before reconnecting.
Fortunately the mechanism already supports a reconnect delay, so here we
compute the random timeout when killing a session. The delay is 50ms plus
a random between 0 and 2 seconds. Ideally an exponential back-off would
be preferred but it's preferable to keep the fix simple.

This bug was reported by Marco Corte.

This fix must be backported to 1.5 since the fix above was backported into
1.5.12.
src/peers.c