Skip to content

Commit 8a872b0

Browse files
committed
varnishd: add VSC per backend connection closed
Change vbe_close_acct to update counters for the specific backend as well as the existing global counters. This addition allows a user to easily pinpoint the problematic backend. As some backends can come and go (dynamic backends), we should maintain the global counters as is. Signed-off-by: Asad Sajjad Ahmed <asadsa@varnish-software.com>
1 parent 725e716 commit 8a872b0

File tree

4 files changed

+100
-3
lines changed

4 files changed

+100
-3
lines changed

bin/varnishd/cache/cache_backend.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,20 +189,25 @@ vbe_connwait_fini(struct connwait *cw)
189189
*/
190190

191191
static void
192-
vbe_close_acct(const struct pfd *pfd, const stream_close_t reason)
192+
vbe_close_acct(const struct pfd *pfd, struct VSC_vbe *vsc,
193+
const stream_close_t reason)
193194
{
194195

195196
if (reason == SC_NULL) {
196197
assert(PFD_State(pfd) == PFD_STATE_USED);
197198
VSC_C_main->bc_tx_proxy++;
199+
vsc->tx_proxy++;
198200
return;
199201
}
200202

201203
#define SESS_CLOSE(U, l, err, desc) \
202204
if (reason == SC_ ## U) { \
203205
VSC_C_main->bc_ ## l++; \
204-
if (err) \
206+
vsc->l++; \
207+
if (err) { \
205208
VSC_C_main->backend_closed_err++; \
209+
vsc->closed_err++; \
210+
} \
206211
return; \
207212
}
208213
#include "tbl/sess_close.h"
@@ -222,20 +227,22 @@ vbe_dir_finish(VRT_CTX, VCL_BACKEND d)
222227
bo = ctx->bo;
223228
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
224229
CAST_OBJ_NOTNULL(bp, d->priv, BACKEND_MAGIC);
230+
AN(bp->vsc);
225231

226232
CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC);
227233
CHECK_OBJ_NOTNULL(bo->htc->doclose, STREAM_CLOSE_MAGIC);
228234

229235
pfd = bo->htc->priv;
230236
bo->htc->priv = NULL;
231237
if (bo->htc->doclose != SC_NULL || bp->proxy_header != 0) {
232-
vbe_close_acct(pfd, bo->htc->doclose);
238+
vbe_close_acct(pfd, bp->vsc, bo->htc->doclose);
233239
VSLb(bo->vsl, SLT_BackendClose, "%d %s close %s", *PFD_Fd(pfd),
234240
VRT_BACKEND_string(d), bo->htc->doclose->name);
235241
VCP_Close(&pfd);
236242
AZ(pfd);
237243
Lck_Lock(bp->director->mtx);
238244
VSC_C_main->backend_closed++;
245+
bp->vsc->closed++;
239246
} else {
240247
assert (PFD_State(pfd) == PFD_STATE_USED);
241248
VSLb(bo->vsl, SLT_BackendClose, "%d %s recycle", *PFD_Fd(pfd),

bin/varnishtest/tests/o00007.vtc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,11 @@ varnish v1 -expect MAIN.bc_tx_proxy == 0
4040
varnish v1 -expect VBE.vcl1.default.conn == 0
4141
varnish v1 -expect VBE.vcl1.default.req == 0
4242
varnish v1 -expect VBE.vcl1.default.fail == 0
43+
varnish v1 -expect VBE.vcl1.default.closed == 1
44+
varnish v1 -expect VBE.vcl1.default.closed_err == 1
45+
46+
varnish v1 -expect VBE.vcl1.default.rx_bad == 0
47+
varnish v1 -expect VBE.vcl1.default.rem_close == 0
48+
varnish v1 -expect VBE.vcl1.default.rx_timeout == 0
49+
varnish v1 -expect VBE.vcl1.default.tx_error == 1
50+
varnish v1 -expect VBE.vcl1.default.tx_proxy == 0

bin/varnishtest/tests/u00008.vtc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ process p1 -winsz 25 132
7070
process p1 -expect-text 4 124 "AVG_1000"
7171
process p1 -expect-text 22 108 "UNSEEN DIAG"
7272

73+
process p1 -key NPAGE
7374
process p1 -key NPAGE
7475
process p1 -expect-text 0 0 "VBE.vcl1.s1.helddown"
7576
process p1 -screen_dump
7677

78+
process p1 -key PPAGE
7779
process p1 -key PPAGE
7880
process p1 -expect-text 0 0 "VBE.vcl1.s1.happy"
7981
process p1 -screen_dump

lib/libvsc/VSC_vbe.vsc

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,86 @@
104104

105105
Number of times the max_connections limit was reached
106106

107+
.. varnish_vsc:: closed
108+
:type: counter
109+
:level: info
110+
:oneliner: Connection closed
111+
112+
.. varnish_vsc:: closed_err
113+
:type: counter
114+
:level: info
115+
:oneliner: Connection closed with error
116+
117+
.. varnish_vsc:: rem_close
118+
:type: counter
119+
:level: info
120+
:oneliner: Connection closed by backend
121+
122+
.. varnish_vsc:: req_close
123+
:type: counter
124+
:level: info
125+
:oneliner: Connection closure requested by backend
126+
127+
.. varnish_vsc:: req_http10
128+
:type: counter
129+
:level: info
130+
:oneliner: Connection closed for proto < HTTP/1.1
131+
132+
.. varnish_vsc:: rx_bad
133+
:type: counter
134+
:level: info
135+
:oneliner: Connection closed for received bad response
136+
137+
.. varnish_vsc:: rx_body
138+
:type: counter
139+
:level: info
140+
:oneliner: Connection closed for failed receiving request body
141+
142+
.. varnish_vsc:: rx_junk
143+
:type: counter
144+
:level: info
145+
:oneliner: Connection closed for received junk data
146+
147+
.. varnish_vsc:: rx_overflow
148+
:type: counter
149+
:level: info
150+
:oneliner: Connection closed for receive buffer overflow
151+
152+
.. varnish_vsc:: rx_timeout
153+
:type: counter
154+
:level: info
155+
:oneliner: Connection closed for receive timeout
156+
157+
.. varnish_vsc:: tx_proxy
158+
:type: counter
159+
:level: info
160+
:oneliner: Connection closed for proxy transaction
161+
162+
.. varnish_vsc:: tx_pipe
163+
:type: counter
164+
:level: info
165+
:oneliner: Connection closed for piped transaction
166+
167+
.. varnish_vsc:: tx_error
168+
:type: counter
169+
:level: info
170+
:oneliner: Connection closed for error transaction
171+
172+
.. varnish_vsc:: tx_eof
173+
:type: counter
174+
:level: info
175+
:oneliner: Connection closed for EOF transmission
176+
177+
.. varnish_vsc:: resp_close
178+
:type: counter
179+
:level: info
180+
:oneliner: Connection closed for backend/VCL requested close
181+
182+
.. varnish_vsc:: overload
183+
:type: counter
184+
:level: info
185+
:oneliner: Connection closed for out of some resource
186+
107187
..
108188
=== Anything below is actually per VCP entry, but collected per
109189
=== backend for simplicity

0 commit comments

Comments
 (0)