]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEBUG: stream: count the number of passes in the connect loop
authorWilly Tarreau <w@1wt.eu>
Tue, 9 Sep 2025 05:05:26 +0000 (07:05 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 9 Sep 2025 15:56:14 +0000 (17:56 +0200)
Normally the connect loop cannot loop, but some recent traces can easily
convince one of the opposite. Let's add a counter, including in panic
dumps, in order to avoid the repeated long head scratching sessions
starting with "and what if...". In addition, if it's found to loop, this
time it will be certain and will indicate what to zoom in. This should
be backported to 3.2.

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

index 83db4cc20e3ee504894cfd735a0314a666ce9c1d..06f7e4be0782e85bb6cbd9ccb137fb28180ed722 100644 (file)
@@ -274,10 +274,12 @@ struct stream {
        uint64_t lat_time;              /* total latency time experienced */
        uint64_t cpu_time;              /* total CPU time consumed */
        struct freq_ctr call_rate;      /* stream task call rate without making progress */
+       uint32_t passes_connect;        /* number of passes on the connect processing loop */
        uint32_t passes_stconn;         /* number of passes on the stconn evaluation code */
        uint32_t passes_reqana;         /* number of passes on the req analysers block */
        uint32_t passes_resana;         /* number of passes on the res analysers block */
        uint32_t passes_propag;         /* number of passes on the shut/err propag code */
+       /* 4 unused bytes here */
 
        unsigned short max_retries;     /* Maximum number of connection retried (=0 is backend is not set) */
        short store_count;
index 470079d0600a0604207bbc36cfd7847760c98283..c6e2d33f11c3556bca9db86ad0112951d6d7eba3 100644 (file)
@@ -424,7 +424,7 @@ struct stream *stream_new(struct session *sess, struct stconn *sc, struct buffer
 
        s->lat_time = s->cpu_time = 0;
        s->call_rate.curr_tick = s->call_rate.curr_ctr = s->call_rate.prev_ctr = 0;
-       s->passes_stconn = s->passes_reqana = s->passes_resana = s->passes_propag = 0;
+       s->passes_connect = s->passes_stconn = s->passes_reqana = s->passes_resana = s->passes_propag = 0;
        s->pcli_next_pid = 0;
        s->pcli_flags = 0;
        s->unique_id = IST_NULL;
@@ -2359,6 +2359,8 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
                }
 
                do {
+                       s->passes_connect++;
+
                        /* nb: step 1 might switch from QUE to ASS, but we first want
                         * to give a chance to step 2 to perform a redirect if needed.
                         */
@@ -3378,8 +3380,8 @@ static void __strm_dump_to_buffer(struct buffer *buf, const struct show_sess_ctx
                     strm->conn_err_type, strm->srv_conn, strm->pend_pos,
                     LIST_INLIST(&strm->buffer_wait.list), strm->stream_epoch);
 
-       chunk_appendf(buf, "%s  p_stc=%u p_req=%u p_res=%u p_prp=%u\n", pfx,
-                     strm->passes_stconn, strm->passes_reqana, strm->passes_resana, strm->passes_propag);
+       chunk_appendf(buf, "%s  p_con=%u p_stc=%u p_req=%u p_res=%u p_prp=%u\n", pfx,
+                     strm->passes_connect, strm->passes_stconn, strm->passes_reqana, strm->passes_resana, strm->passes_propag);
 
        chunk_appendf(buf,
                     "%s  frontend=%s (id=%u mode=%s), listener=%s (id=%u)", pfx,