From: Christopher Faulet Date: Tue, 18 Nov 2025 15:08:18 +0000 (+0100) Subject: WIP/MEDIUM: peers: Start resynchro of a stick-table from a random bucket X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7241907bd3375ccb11bb9ae0e015faac809338e3;p=thirdparty%2Fhaproxy.git WIP/MEDIUM: peers: Start resynchro of a stick-table from a random bucket --- diff --git a/include/haproxy/peers-t.h b/include/haproxy/peers-t.h index f1ae7652e..f9a521bcf 100644 --- a/include/haproxy/peers-t.h +++ b/include/haproxy/peers-t.h @@ -134,7 +134,8 @@ static forceinline char *peer_show_flags(char *buf, size_t len, const char *deli struct shared_table { struct stktable *table; /* stick table to sync */ struct stksess *ts; /* next sticky session to send (only during a full resync) */ - unsigned int bucket; /* current bucket explored (only during a full resync) */ + unsigned int init_bucket; /* starting bucket (only during a full resync) */ + unsigned int bucket; /* current bucket (only during a full resync) */ unsigned int resync_end; /* date to stop resync (session with expiration beyond this date are ignored during resync) */ int local_id; int remote_id; diff --git a/src/peers.c b/src/peers.c index 3dfaae71e..1e2537d6c 100644 --- a/src/peers.c +++ b/src/peers.c @@ -1615,7 +1615,7 @@ int peer_send_resync_updates(struct appctx *appctx, struct peer *p, struct share new_pushed = 1; /* This stick-table was already fully sync */ - if (st->bucket >= CONFIG_HAP_TBL_BUCKETS) + if (st->ts == NULL && st->bucket == st->init_bucket && tick_isset(st->resync_end)) goto out; /* Be sure to set the stop point to not resync infinitly */ @@ -1637,6 +1637,8 @@ int peer_send_resync_updates(struct appctx *appctx, struct peer *p, struct share HA_RWLOCK_RDUNLOCK(STK_TABLE_LOCK, &st->table->buckets[st->bucket].sh_lock); st->bucket++; if (st->bucket >= CONFIG_HAP_TBL_BUCKETS) + st->bucket = 0; + if (st->bucket == st->init_bucket) break; goto next; } @@ -2610,7 +2612,7 @@ static inline int peer_treat_awaited_msg(struct appctx *appctx, struct peer *pee for (st = peer->tables; st; st = st->next) { st->ts = NULL; st->bucket = 0; - st->resync_end = TICK_ETERNITY; + st->bucket = st->init_bucket = statistical_prng_range(CONFIG_HAP_TBL_BUCKETS - 1); st->flags = 0; } @@ -2984,7 +2986,7 @@ static inline void init_connected_peer(struct peer *peer, struct peers *peers) st->last_get = st->last_acked = 0; st->last_pushed = HA_ATOMIC_LOAD(&st->update); st->ts = NULL; - st->bucket = 0; + st->bucket = st->init_bucket = statistical_prng_range(CONFIG_HAP_TBL_BUCKETS - 1); st->resync_end = TICK_ETERNITY; st->flags = 0; }