Permalink
Browse files

Replace FetchError "no backend connection" with something more useful

Previously, a FetchError in vbe_dir_getfd() was too general to be
useful. Now we log an error with the same identifier as the
corresponding statistic:

* unhealthy
* busy (max_connections reached)
* fail (no connection for real)

For these, we also log the backend name because we have not yet issued
a BackendOpen VSL.

A failed WS_Alloc is logged as "out of workspace".
  • Loading branch information...
nigoroll committed Oct 6, 2017
1 parent 9f6c0de commit 75fe1e48ce49cbf66c759d1283cf152d673d5d85
Showing with 11 additions and 6 deletions.
  1. +10 −5 bin/varnishd/cache/cache_backend.c
  2. +1 −1 bin/varnishtest/tests/r01990.vtc
@@ -77,27 +77,35 @@ vbe_dir_getfd(struct worker *wrk, struct backend *bp, struct busyobj *bo)
AN(bp->vsc);
if (!VBE_Healthy(bp, NULL)) {
VSLb(bo->vsl, SLT_FetchError,
"backend %s: unhealthy", bp->display_name);
// XXX: per backend stats ?
VSC_C_main->backend_unhealthy++;
return (NULL);
}
if (bp->max_connections > 0 && bp->n_conn >= bp->max_connections) {
VSLb(bo->vsl, SLT_FetchError,
"backend %s: busy", bp->display_name);
// XXX: per backend stats ?
VSC_C_main->backend_busy++;
return (NULL);
}
AZ(bo->htc);
bo->htc = WS_Alloc(bo->ws, sizeof *bo->htc);
if (bo->htc == NULL)
if (bo->htc == NULL) {
VSLb(bo->vsl, SLT_FetchError, "out of workspace");
/* XXX: counter ? */
return (NULL);
}
bo->htc->doclose = SC_NULL;
FIND_TMO(connect_timeout, tmod, bo, bp);
vtp = VTP_Get(bp->tcp_pool, tmod, wrk);
if (vtp == NULL) {
VSLb(bo->vsl, SLT_FetchError,
"backend %s: fail", bp->display_name);
// XXX: Per backend stats ?
VSC_C_main->backend_fail++;
bo->htc = NULL;
@@ -204,10 +212,8 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
do {
vtp = vbe_dir_getfd(wrk, bp, bo);
if (vtp == NULL) {
VSLb(bo->vsl, SLT_FetchError, "no backend connection");
if (vtp == NULL)
return (-1);
}
AN(bo->htc);
if (vtp->state != VTP_STATE_STOLEN)
extrachance = 0;
@@ -286,7 +292,6 @@ vbe_dir_http1pipe(const struct director *d, struct req *req, struct busyobj *bo)
vtp = vbe_dir_getfd(req->wrk, bp, bo);
if (vtp == NULL) {
VSLb(bo->vsl, SLT_FetchError, "no backend connection");
retval = SC_TX_ERROR;
} else {
i = V1F_SendReq(req->wrk, bo, &v1a.bereq, 1);
@@ -23,7 +23,7 @@ varnish v1 -vcl {
} -start
logexpect l1 -v v1 -g raw {
expect * 1002 FetchError {^no backend connection}
expect * 1002 FetchError {^out of workspace}
expect * = BerespStatus {^503}
expect * = BerespReason {^Backend fetch failed}
expect * = Error {^out of workspace [(]Bo[)]}

0 comments on commit 75fe1e4

Please sign in to comment.