[6.0] fbc455e7a Add client_resp_500 counter

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Wed Oct 31 13:08:30 UTC 2018


commit fbc455e7a635d8e348983ff45fce5ff5730ff1b3
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.
    
    Conflicts:
            bin/varnishtest/tests/v00058.vtc

diff --git a/bin/varnishd/VSC_main.vsc b/bin/varnishd/VSC_main.vsc
index 88a22bb86..da1306f36 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 fda38dda4..88447b5a6 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -75,6 +75,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 8f4b56e1d..de55887ae 100644
--- a/bin/varnishd/http2/cache_http2_deliver.c
+++ b/bin/varnishd/http2/cache_http2_deliver.c
@@ -263,7 +263,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


More information about the varnish-commit mailing list