WIP/MEDIUM: peers: Start resynchro of a stick-table from a random bucket
Some checks failed
Contrib / build (push) Has been cancelled
alpine/musl / gcc (push) Has been cancelled
VTest / Generate Build Matrix (push) Has been cancelled
Windows / Windows, gcc, all features (push) Has been cancelled
VTest / (push) Has been cancelled

This commit is contained in:
Christopher Faulet 2025-11-18 16:08:18 +01:00
parent 04012ae816
commit 7241907bd3
2 changed files with 7 additions and 4 deletions

View file

@ -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;

View file

@ -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;
}