[master] 75fe1e4 Replace FetchError "no backend connection" with something more useful
Nils Goroll
nils.goroll at uplex.de
Fri Oct 6 11:36:05 UTC 2017
commit 75fe1e48ce49cbf66c759d1283cf152d673d5d85
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Fri Oct 6 13:29:46 2017 +0200
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".
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 0956afb..b344770 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -77,12 +77,16 @@ 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);
@@ -90,14 +94,18 @@ vbe_dir_getfd(struct worker *wrk, struct backend *bp, struct busyobj *bo)
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);
diff --git a/bin/varnishtest/tests/r01990.vtc b/bin/varnishtest/tests/r01990.vtc
index 2b9dbbd..5ee40bd 100644
--- a/bin/varnishtest/tests/r01990.vtc
+++ b/bin/varnishtest/tests/r01990.vtc
@@ -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[)]}
More information about the varnish-commit
mailing list