]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: lb_fwrr: Don't start all thread groups on the same server.
authorOlivier Houchard <ohouchard@haproxy.com>
Thu, 17 Apr 2025 14:45:29 +0000 (16:45 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 17 Apr 2025 15:38:23 +0000 (17:38 +0200)
Now that all there is one tree per thread group, all thread groups will
start on the same server. To prevent that, just insert the servers in a
different order for each thread group.

src/lb_fwrr.c

index 3958951616d85635e9b5b5d17324d85af51f02d3..26fca7c4aaae1814cf60ee3f0dce880f8e357aac 100644 (file)
@@ -297,7 +297,7 @@ void fwrr_init_server_groups(struct proxy *p)
 {
        struct server *srv;
        struct eb_root init_head = EB_ROOT;
-       int i;
+       int i, j;
 
        p->lbprm.set_server_status_up   = fwrr_set_server_status_up;
        p->lbprm.set_server_status_down = fwrr_set_server_status_down;
@@ -334,7 +334,21 @@ void fwrr_init_server_groups(struct proxy *p)
                p->per_tgrp[i].lbprm.fwrr.bck.next = &p->per_tgrp[i].lbprm.fwrr.bck.t1;
 
                /* queue active and backup servers in two distinct groups */
+               j = 0;
                for (srv = p->srv; srv; srv = srv->next) {
+                       j++;
+                       if (!srv_currently_usable(srv))
+                               continue;
+                       if (j <= i)
+                               continue;
+                       fwrr_queue_by_weight((srv->flags & SRV_F_BACKUP) ?
+                                       p->per_tgrp[i].lbprm.fwrr.bck.init :
+                                       p->per_tgrp[i].lbprm.fwrr.act.init,
+                                       srv, i + 1);
+               }
+               j = 0;
+               for (srv = p->srv; srv && j < i; srv = srv->next) {
+                       j++;
                        if (!srv_currently_usable(srv))
                                continue;
                        fwrr_queue_by_weight((srv->flags & SRV_F_BACKUP) ?