]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: backend: use cum_sess counters instead of cum_conn
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 4 Apr 2024 16:08:46 +0000 (18:08 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 22 Apr 2024 08:35:18 +0000 (10:35 +0200)
This commit is part of a serie to align counters usage between
frontends/listeners on one side and backends/servers on the other.

"stot" metric refers to the total number of sessions. On backend side,
it is interpreted as a number of streams. Previously, this was accounted
using <cum_sess> be_counters field for servers, but <cum_conn> instead
for backend proxies.

Adjust this by using <cum_sess> for both proxies and servers. As such,
<cum_conn> field can be removed from be_counters.

Note that several diagnostic messages which reports total frontend and
backend connections were adjusted to use <cum_sess>. However, this is an
outdated and misleading information as it does reports streams count on
backend side. These messages should be fixed in a separate commit.

This should be backported to all stable releases.

include/haproxy/counters-t.h
include/haproxy/proxy.h
include/haproxy/server.h
src/haproxy.c
src/proxy.c
src/stats.c

index 933c228f05b1619bd0d5353c63baf791eaf463dc..8ba6322649fe16d48e9f8638c96767e4a1d324d8 100644 (file)
@@ -68,7 +68,6 @@ struct fe_counters {
 /* counters used by servers and backends */
 struct be_counters {
        unsigned int conn_max;                  /* max # of active sessions */
-       long long    cum_conn;                  /* cumulated number of received connections */
        long long    cum_sess;                  /* cumulated number of accepted connections */
        long long  cum_lbconn;                  /* cumulated number of sessions processed by load balancing (BE only) */
        unsigned long last_sess;                /* last session time */
index 01b0f17b5e57700b9e29112668e5aea810c1c86c..c3ab1701b876a88b6aef3102720e8218d93d8caa 100644 (file)
@@ -163,10 +163,10 @@ static inline void proxy_inc_fe_cum_sess_ver_ctr(struct listener *l, struct prox
                _HA_ATOMIC_INC(&l->counters->cum_sess_ver[http_ver - 1]);
 }
 
-/* increase the number of cumulated connections on the designated backend */
+/* increase the number of cumulated streams on the designated backend */
 static inline void proxy_inc_be_ctr(struct proxy *be)
 {
-       _HA_ATOMIC_INC(&be->be_counters.cum_conn);
+       _HA_ATOMIC_INC(&be->be_counters.cum_sess);
        HA_ATOMIC_UPDATE_MAX(&be->be_counters.sps_max,
                             update_freq_ctr(&be->be_sess_per_sec, 1));
 }
index 18b4d38748fbda59b56d3ec6eee8ea234a909a8a..cb1c3c54946bf52302d4ce5dc359a60d8b777890 100644 (file)
@@ -176,7 +176,7 @@ void srv_set_dyncookie(struct server *s);
 int srv_check_reuse_ws(struct server *srv);
 const struct mux_ops *srv_get_ws_proto(struct server *srv);
 
-/* increase the number of cumulated connections on the designated server */
+/* increase the number of cumulated streams on the designated server */
 static inline void srv_inc_sess_ctr(struct server *s)
 {
        _HA_ATOMIC_INC(&s->counters.cum_sess);
index 79059b97a12e2c6dd032a16ee19ab0860f83615b..a5fa6dfcd16bcbd1ca58d81ec3e5e499de0cb554 100644 (file)
@@ -1006,19 +1006,19 @@ static void sig_dump_state(struct sig_handler *sh)
                        chunk_printf(&trash,
                                     "SIGHUP: Proxy %s has no servers. Conn: act(FE+BE): %d+%d, %d pend (%d unass), tot(FE+BE): %lld+%lld.",
                                     p->id,
-                                    p->feconn, p->beconn, p->totpend, p->queue.length, p->fe_counters.cum_conn, p->be_counters.cum_conn);
+                                    p->feconn, p->beconn, p->totpend, p->queue.length, p->fe_counters.cum_conn, p->be_counters.cum_sess);
                } else if (p->srv_act == 0) {
                        chunk_printf(&trash,
                                     "SIGHUP: Proxy %s %s ! Conn: act(FE+BE): %d+%d, %d pend (%d unass), tot(FE+BE): %lld+%lld.",
                                     p->id,
                                     (p->srv_bck) ? "is running on backup servers" : "has no server available",
-                                    p->feconn, p->beconn, p->totpend, p->queue.length, p->fe_counters.cum_conn, p->be_counters.cum_conn);
+                                    p->feconn, p->beconn, p->totpend, p->queue.length, p->fe_counters.cum_conn, p->be_counters.cum_sess);
                } else {
                        chunk_printf(&trash,
                                     "SIGHUP: Proxy %s has %d active servers and %d backup servers available."
                                     " Conn: act(FE+BE): %d+%d, %d pend (%d unass), tot(FE+BE): %lld+%lld.",
                                     p->id, p->srv_act, p->srv_bck,
-                                    p->feconn, p->beconn, p->totpend, p->queue.length, p->fe_counters.cum_conn, p->be_counters.cum_conn);
+                                    p->feconn, p->beconn, p->totpend, p->queue.length, p->fe_counters.cum_conn, p->be_counters.cum_sess);
                }
                ha_warning("%s\n", trash.area);
                send_log(p, LOG_NOTICE, "%s\n", trash.area);
index 92c5df143af4d10b33b884223ad0cfd01d396e9d..e5ba7bf120a724f9263e689cbc67a4de29f2553d 100644 (file)
@@ -1889,11 +1889,11 @@ void proxy_cond_disable(struct proxy *p)
         */
        if ((p->mode == PR_MODE_TCP || p->mode == PR_MODE_HTTP || p->mode == PR_MODE_SYSLOG) && !(p->cap & PR_CAP_INT))
                ha_warning("Proxy %s stopped (cumulated conns: FE: %lld, BE: %lld).\n",
-                          p->id, p->fe_counters.cum_conn, p->be_counters.cum_conn);
+                          p->id, p->fe_counters.cum_conn, p->be_counters.cum_sess);
 
        if ((p->mode == PR_MODE_TCP || p->mode == PR_MODE_HTTP) && !(p->cap & PR_CAP_INT))
                send_log(p, LOG_WARNING, "Proxy %s stopped (cumulated conns: FE: %lld, BE: %lld).\n",
-                        p->id, p->fe_counters.cum_conn, p->be_counters.cum_conn);
+                        p->id, p->fe_counters.cum_conn, p->be_counters.cum_sess);
 
        if (p->table && p->table->size && p->table->sync_task)
                task_wakeup(p->table->sync_task, TASK_WOKEN_MSG);
index 959dc3593cb07e918ab699b070920bb60379577f..3c44afe663b6856256bb5ecd125b5fbcb1acd06f 100644 (file)
@@ -1645,7 +1645,7 @@ int stats_fill_be_stats(struct proxy *px, int flags, struct field *stats, int le
                                metric = mkf_u32(FO_CONFIG|FN_LIMIT, px->fullconn);
                                break;
                        case ST_F_STOT:
-                               metric = mkf_u64(FN_COUNTER, px->be_counters.cum_conn);
+                               metric = mkf_u64(FN_COUNTER, px->be_counters.cum_sess);
                                break;
                        case ST_F_BIN:
                                metric = mkf_u64(FN_COUNTER, px->be_counters.bytes_in);