BUG/MAJOR: mux_pt: always report the connection error to the conn_stream

Over time we've tried hard to abstract connection errors from the upper
layers so that they're reported per stream and not per connection. As
early as 1.8-rc1, commit 4ff3b8964 ("MINOR: connection: make conn_stream
users also check for per-stream error flag") did precisely this, but
strangely only for rx, not for tx (probably that by then send errors
were not imagined to be reported that way).

And this lack of Tx error check was just revealed in 2.6 by recent commit
d1480cc8a ("BUG/MEDIUM: stream-int: do not rely on the connection error
once established") that causes wakeup loops between si_cs_send() failing
to send via mux_pt_snd_buf() and subscribing against si_cs_io_cb() in
loops because the function now rightfully only checks for CS_FL_ERROR
and not CO_FL_ERROR.

As found by Amaury, this causes aborted "show events -w" to cause
haproxy to loop at 100% CPU.

This fix theoretically needs to be backported to all versions, though
it will be necessary and sufficient to backport it wherever 4ff3b8964
gets backported.
This commit is contained in:
Willy Tarreau 2022-03-31 16:47:46 +02:00
parent a662275e84
commit 413713f02a

View File

@ -535,6 +535,11 @@ static size_t mux_pt_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t
if (ret > 0) if (ret > 0)
b_del(buf, ret); b_del(buf, ret);
if (conn->flags & CO_FL_ERROR) {
cs->flags |= CS_FL_ERROR;
TRACE_DEVEL("error on connection", PT_EV_TX_DATA|PT_EV_CONN_ERR, conn, cs);
}
TRACE_LEAVE(PT_EV_TX_DATA, conn, cs, buf, (size_t[]){ret}); TRACE_LEAVE(PT_EV_TX_DATA, conn, cs, buf, (size_t[]){ret});
return ret; return ret;
} }
@ -596,6 +601,11 @@ static int mux_pt_snd_pipe(struct conn_stream *cs, struct pipe *pipe)
ret = conn->xprt->snd_pipe(conn, conn->xprt_ctx, pipe); ret = conn->xprt->snd_pipe(conn, conn->xprt_ctx, pipe);
if (conn->flags & CO_FL_ERROR) {
cs->flags |= CS_FL_ERROR;
TRACE_DEVEL("error on connection", PT_EV_TX_DATA|PT_EV_CONN_ERR, conn, cs);
}
TRACE_LEAVE(PT_EV_TX_DATA, conn, cs, 0, (size_t[]){ret}); TRACE_LEAVE(PT_EV_TX_DATA, conn, cs, 0, (size_t[]){ret});
return ret; return ret;
} }