BUG/MEDIUM: peers: re-work refcnt on table to protect against flush
authorEmeric Brun <ebrun@haproxy.com>
Fri, 23 Apr 2021 15:02:22 +0000 (17:02 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 23 Apr 2021 16:12:10 +0000 (18:12 +0200)
commit167b783bce9c4cd7ca99f09f3a2202ddc72dec4f
treebad47bc7028ea93834e15a7dfe867486d6ab6c21
parent1efabf19523992a431358fbb2c93e5cf53653015
BUG/MEDIUM: peers: re-work refcnt on table to protect against flush

In proxy.c, when process is stopping we try to flush tables content
using 'stktable_trash_oldest'. A check on a counter "table->syncing" was
made to verify if there is no pending resync in progress.
But using multiple threads this counter can be increased by an other thread
only after some delay, so the content of some tables can be trashed earlier and
won't be pushed to the new process (after reload, some tables appear reset and
others don't).

This patch re-names the counter "table->syncing" to "table->refcnt" and
the counter is increased during configuration parsing (registering a table to
a peer section) to protect tables during runtime and until resync of a new
process has succeeded or failed.

The inc/dec operations are now made using atomic operations
because multiple peer sections could refer to the same table in futur.

This fix addresses github #1216.

This patch should be backported on all branches multi-thread support (v >= 1.8)

(cherry picked from commit 2cc201f97e409f926b9221fdafe7431877ba1dc6)
Signed-off-by: Emeric Brun <ebrun@haproxy.com>
include/haproxy/stick_table-t.h
src/peers.c
src/proxy.c