[master] ff31e8aff Add client_resp_500 counter

Dag Haavi Finstad daghf at varnish-software.com
Fri Oct 12 14:52:09 UTC 2018


commit ff31e8aff56057ba92b98726187b858618f52c13
Author: Dag Haavi Finstad <daghf at varnish-software.com>
Date:   Wed Oct 10 13:41:28 2018 +0200

    Add client_resp_500 counter
    
    Counts the number of times we failed a response due to running out of
    workspace during delivery.

diff --git a/bin/varnishd/VSC_main.vsc b/bin/varnishd/VSC_main.vsc
index 8ca97887e..8a2fa4610 100644
--- a/bin/varnishd/VSC_main.vsc
+++ b/bin/varnishd/VSC_main.vsc
@@ -586,6 +586,14 @@
 
 	Number of session closes with Error VCL_FAILURE (VCL failure)
 
+.. varnish_vsc:: client_resp_500
+	:level: diag
+	:group: wrk
+	:oneliner:	Delivery failed due to insufficient workspace.
+
+	Number of times we failed a response due to running out of
+	workspace memory during delivery.
+
 .. varnish_vsc:: shm_records
 	:level:	diag
 	:oneliner:	SHM records
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index 7c617ebe7..c0fce16d3 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -73,6 +73,7 @@ v1d_error(struct req *req, const char *msg)
 	VSLb(req->vsl, SLT_RespStatus, "500");
 	VSLb(req->vsl, SLT_RespReason, "Internal Server Error");
 
+	req->wrk->stats->client_resp_500++;
 	(void)write(req->sp->fd, r_500, sizeof r_500 - 1);
 	req->doclose = SC_TX_EOF;
 }
diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c
index 5ca7ee3c3..c7d1ad32e 100644
--- a/bin/varnishd/http2/cache_http2_deliver.c
+++ b/bin/varnishd/http2/cache_http2_deliver.c
@@ -274,7 +274,11 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody)
 	}
 	if (VSB_finish(&resp)) {
 		// We ran out of workspace, return minimal 500
-		// XXX: VSC counter ?
+		VSLb(req->vsl, SLT_Error, "workspace_client overflow");
+		VSLb(req->vsl, SLT_RespStatus, "500");
+		VSLb(req->vsl, SLT_RespReason, "Internal Server Error");
+		req->wrk->stats->client_resp_500++;
+
 		r = (const char*)h2_500_resp;
 		sz = sizeof h2_500_resp;
 		sendbody = 0;
diff --git a/bin/varnishtest/tests/c00070.vtc b/bin/varnishtest/tests/c00070.vtc
index 659356935..4ecf82671 100644
--- a/bin/varnishtest/tests/c00070.vtc
+++ b/bin/varnishtest/tests/c00070.vtc
@@ -67,3 +67,5 @@ client c1 {
 } -run
 
 logexpect l2 -wait
+
+varnish v1 -expect client_resp_500 == 1
diff --git a/bin/varnishtest/tests/c00071.vtc b/bin/varnishtest/tests/c00071.vtc
index c0ebbc294..8ebddc490 100644
--- a/bin/varnishtest/tests/c00071.vtc
+++ b/bin/varnishtest/tests/c00071.vtc
@@ -46,3 +46,5 @@ client c2 {
 	expect resp.http.x-of == <undef>
 } -run
 
+
+varnish v1 -expect client_resp_500 == 2
diff --git a/bin/varnishtest/tests/r02233.vtc b/bin/varnishtest/tests/r02233.vtc
index 67fb20c9c..fe36fccb2 100644
--- a/bin/varnishtest/tests/r02233.vtc
+++ b/bin/varnishtest/tests/r02233.vtc
@@ -28,3 +28,4 @@ client c1 {
 } -run
 
 logexpect l1 -wait
+varnish v1 -expect client_resp_500 == 1
diff --git a/bin/varnishtest/tests/r02589.vtc b/bin/varnishtest/tests/r02589.vtc
index 418cc6833..2c43ab6fc 100644
--- a/bin/varnishtest/tests/r02589.vtc
+++ b/bin/varnishtest/tests/r02589.vtc
@@ -27,3 +27,5 @@ client c1 {
 		expect resp.http.server == "Varnish"
 	} -run
 } -run
+
+varnish v1 -expect client_resp_500 == 1
diff --git a/bin/varnishtest/tests/v00058.vtc b/bin/varnishtest/tests/v00058.vtc
index bb6aa869a..96c3972ef 100644
--- a/bin/varnishtest/tests/v00058.vtc
+++ b/bin/varnishtest/tests/v00058.vtc
@@ -164,3 +164,5 @@ client c1 {
 	expect resp.status >= 500
 	expect resp.status <= 503
 } -run
+
+varnish v1 -expect client_resp_500 == 1


More information about the varnish-commit mailing list