]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: peers: Separate id of update messages from the update tree
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 8 Oct 2025 15:48:23 +0000 (17:48 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 21 Oct 2025 13:04:59 +0000 (15:04 +0200)
Now the updates are no longer tracked by stick-table and we are no longer
use their id to detect missed updates, there is no reason to have a matching
between the internal update id in the id used in updated messages.

So, now, for a given peer, id of the last update messages sent is saved in
each shared table and it is incremented when a new message is updated.

include/haproxy/peers-t.h
src/peers.c

index 439e9ce0e74c2cf0bc9324dd6b78898481e6d022..981b8963fa1e45d4db32c7459b67d33143841fcf 100644 (file)
@@ -137,6 +137,7 @@ struct shared_table {
        int local_id;
        int remote_id;
        int flags;
+       unsigned int update_id;
        uint64_t remote_data;
        unsigned int remote_data_nbelem[STKTABLE_DATA_TYPES];
        unsigned int last_acked;
index e20991eddd5b4b8f76675229a5ccb943e0f80f79..7f041cdfcbf1c0c65d8efe3012db06cd321a8364 100644 (file)
@@ -715,9 +715,8 @@ int peer_prepare_updatemsg(char *msg, size_t size, struct peer_prep_params *p)
        /* construct message */
 
        /* check if we need to send the update identifier */
-       if (!st->last_pushed || updateid < st->last_pushed || ((updateid - st->last_pushed) != 1)) {
+       if (!peer->last.table || updateid < peer->last.id || (updateid - peer->last.id) != 1)
                use_identifier = 1;
-       }
 
        /* encode update identifier if needed */
        if (use_identifier)  {
@@ -1648,7 +1647,7 @@ int peer_send_teachmsgs(struct appctx *appctx, struct peer *p,
 
        while (1) {
                struct stksess *ts;
-               unsigned updateid;
+               unsigned last_pushed;
 
                /* push local updates */
                ts = peer_stksess_lookup(st);
@@ -1657,10 +1656,10 @@ int peer_send_teachmsgs(struct appctx *appctx, struct peer *p,
                        break;
                }
 
-               updateid = ts->upd.key;
+               last_pushed = ts->upd.key;
                if (p->srv->shard && ts->shard != p->srv->shard) {
                        /* Skip this entry */
-                       st->last_pushed = updateid;
+                       st->last_pushed = last_pushed;
                        new_pushed = 1;
                        continue;
                }
@@ -1668,7 +1667,7 @@ int peer_send_teachmsgs(struct appctx *appctx, struct peer *p,
                HA_ATOMIC_INC(&ts->ref_cnt);
                HA_RWLOCK_RDUNLOCK(STK_TABLE_UPDT_LOCK, &st->table->updt_lock);
 
-               ret = peer_send_updatemsg(st, appctx, ts, updateid, new_pushed, use_timed);
+               ret = peer_send_updatemsg(st, appctx, ts, st->update_id, new_pushed, use_timed);
 
                if (HA_RWLOCK_TRYRDLOCK(STK_TABLE_UPDT_LOCK, &st->table->updt_lock) != 0) {
                        if (failed_once) {
@@ -1692,9 +1691,10 @@ int peer_send_teachmsgs(struct appctx *appctx, struct peer *p,
                if (ret <= 0)
                        break;
 
-               st->last_pushed = updateid;
+               st->last_pushed = last_pushed;
                p->last.table = st;
-               p->last.id = updateid;
+               p->last.id = st->update_id;
+               st->update_id++;
                p->flags &= ~PEER_F_SYNCHED;
 
                /* identifier may not needed in next update message */