[master] 70923dc Add SLT tag HitMiss to log hits on hit-for-miss objects.

Geoff Simmons geoff at uplex.de
Tue Mar 7 18:32:05 CET 2017


commit 70923dc0a3e9bed5b5bacffd7c5db8b8c93f886c
Author: Geoff Simmons <geoff at uplex.de>
Date:   Tue Mar 7 16:10:51 2017 +0100

    Add SLT tag HitMiss to log hits on hit-for-miss objects.

diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 7059826..8019591 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -443,6 +443,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
 				oc = NULL;
 			} else if (oc->flags & OC_F_PASS) {
 				wrk->stats->cache_hitmiss++;
+				VSLb(req->vsl, SLT_HitMiss, "%u",
+				     ObjGetXID(wrk, oc));
 				oc = NULL;
 				*bocp = hsh_insert_busyobj(wrk, oh);
 			} else {
@@ -466,6 +468,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
 
 	if (exp_oc != NULL && exp_oc->flags & OC_F_PASS) {
 		wrk->stats->cache_hitmiss++;
+		VSLb(req->vsl, SLT_HitMiss, "%u", ObjGetXID(wrk, exp_oc));
 		exp_oc = NULL;
 		busy_found = 0;
 	}
diff --git a/bin/varnishtest/tests/c00011.vtc b/bin/varnishtest/tests/c00011.vtc
index 02dd470..38a91f2 100644
--- a/bin/varnishtest/tests/c00011.vtc
+++ b/bin/varnishtest/tests/c00011.vtc
@@ -1,4 +1,4 @@
-varnishtest "Test hit for pass (pass from fetch)"
+varnishtest "Test hit for miss (beresp.uncacheable = true)"
 
 server s1 {
 	rxreq
@@ -22,6 +22,10 @@ varnish v1 -vcl+backend {
 	}
 } -start
 
+logexpect l1 -v v1 -g vxid {
+	expect 1003 *	HitMiss "^1002$"
+} -start
+
 client c1 {
 	txreq -url "/foo"
 	rxresp
@@ -49,3 +53,5 @@ client c1 {
 }
 
 client c1 -run
+
+logexpect l1 -wait
diff --git a/bin/varnishtest/tests/r01858.vtc b/bin/varnishtest/tests/r01858.vtc
index 817c469..23ff7c2 100644
--- a/bin/varnishtest/tests/r01858.vtc
+++ b/bin/varnishtest/tests/r01858.vtc
@@ -22,6 +22,11 @@ varnish v1 -vcl+backend {
 	}
 } -start
 
+# Tests logging hit-for-miss on an expired object
+logexpect l1 -v v1 -g vxid {
+	expect 1003 *	HitMiss "^1002$"
+} -start
+
 client c1 {
 	txreq
 	rxresp
@@ -36,3 +41,4 @@ client c1 {
 	expect resp.body == "bar"
 } -run
 
+logexpect l1 -wait
diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h
index 2231b17..e434aac 100644
--- a/include/tbl/vsl_tags.h
+++ b/include/tbl/vsl_tags.h
@@ -541,6 +541,11 @@ SLTM(H2TxBody, 0, "Transmitted HTTP2 frame body",
 	"Binary data"
 )
 
+SLTM(HitMiss, 0, "Hit for miss object in cache.",
+	"Hit-for-miss object looked up in cache. Shows the VXID of the"
+	" hit-for-miss object.\n\n"
+)
+
 #undef NODEF_NOTICE
 #undef SLTM
 



More information about the varnish-commit mailing list