]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: stick-tables: fix double-decrement of tracked entries
authorWilly Tarreau <w@1wt.eu>
Mon, 21 Sep 2015 15:48:24 +0000 (17:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 21 Sep 2015 15:48:24 +0000 (17:48 +0200)
commita68f7629ddc4f12f63f6e1a6703b8f6952393cde
tree88bb77e7bcbfbade183f55b4bfa8e6449e9019e6
parent8f1b35b383b5911e9fd1ac4ff0a1aab244406575
BUG/MEDIUM: stick-tables: fix double-decrement of tracked entries

Mailing list participant "mlist" reported negative conn_cur values in
stick tables as the result of "tcp-request connection track-sc". The
reason is that after the stick entry it copied from the session to the
stream, both the session and the stream grab a reference to the entry
and when the stream ends, it decrements one reference and one connection,
then the same is done for the session.

In fact this problem was already encountered slightly differently in the
past and addressed by Thierry using the patch below as it was believed by
then to be only a refcount issue since it was the observable symptom :

   827752e "BUG/MEDIUM: stick-tables: refcount error after copying SC..."

In reality the problem is that the stream must touch neither the refcount
nor the connection count for entries it inherits from the session. While
we have no way to tell whether a track entry was inherited from the session
(since they're simply memcpy'd), it is possible to prevent the stream from
touching an entry that already exists in the session because that's a
guarantee that it was inherited from it.

Note that it may be a temporary fix. Maybe in the future when a session
gives birth to multiple streams we'll face a situation where a session may
be updated to add more tracked entries after instanciating some streams.
The correct long-term fix is to mark some tracked entries as shared or
private (or RO/RW). That will allow the session to track more entries
even after the same trackers are being used by early streams.

No backport is needed, this is only caused by the session/stream split in 1.6.
include/proto/stream.h
src/stream.c