mirror of
https://github.com/haproxy/haproxy.git
synced 2026-02-18 18:19:39 -05:00
WIP/MEDIUM: peers: Start resynchro of a stick-table from a random bucket
This commit is contained in:
parent
04012ae816
commit
7241907bd3
2 changed files with 7 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue