[4.0] 2b931fe Handle template object failures during condfetch

Lasse Karstensen lkarsten at varnish-software.com
Thu Jan 15 16:35:44 CET 2015


commit 2b931fed8ade30933485833a6a9fd0e3cd1d1db1
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Tue Dec 16 18:14:57 2014 +0100

    Handle template object failures during condfetch
    
    Fixes: #1648
    
    Conflicts:
    	bin/varnishd/cache/cache_fetch.c

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 4743133..9478edc 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -658,6 +658,8 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 	oi = ObjIterBegin(wrk, bo->ims_obj);
 	do {
 		ois = ObjIter(oi, &sp, &sl);
+		if (ois == OIS_ERROR)
+			VFP_Error(bo, "Template object failed");
 		while (sl > 0) {
 			if (st == NULL)
 				st = VFP_GetStorage(bo, bo->ims_obj->len - al);
@@ -676,6 +678,8 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 		}
 	} while (!bo->failed && (ois == OIS_DATA || ois == OIS_STREAM));
 	ObjIterEnd(&oi);
+	if (bo->ims_obj->objcore->flags & OC_F_FAILED)
+		VFP_Error(bo, "Template object failed");
 	if (bo->failed)
 		return (F_STP_FAIL);
 
diff --git a/bin/varnishtest/tests/r01648.vtc b/bin/varnishtest/tests/r01648.vtc
new file mode 100644
index 0000000..de0c364
--- /dev/null
+++ b/bin/varnishtest/tests/r01648.vtc
@@ -0,0 +1,75 @@
+varnishtest "#1648 - corrupt object in cache through IMS update"
+
+# This server sends a broken response body
+server s1 {
+	rxreq
+	txresp -nolen -hdr "Transfer-Encoding: chunked" -hdr "Etag: \"foo\"" -hdr "Server: s1"
+	sema r1 sync 3
+	delay 1
+	chunked "abc"
+} -start
+
+# This server validates the streaming response from s1 as it hasn't failed yet
+server s2 {
+	rxreq
+	expect req.http.If-None-Match == "\"foo\""
+	sema r1 sync 3
+	txresp -status 304 -nolen -hdr "Server: s2"
+} -start
+
+# This server sends the proper response body
+server s3 {
+	rxreq
+	txresp -hdr "Server: s3" -body "abcdef"
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_recv {
+		if (req.http.client == "c1") {
+			set req.backend_hint = s1;
+		} else if (req.http.client == "c2") {
+			set req.backend_hint = s2;
+		} else if (req.http.client == "c3") {
+			set req.backend_hint = s3;
+		}
+	}
+	sub vcl_backend_response {
+		if (bereq.http.client == "c1") {
+			set beresp.ttl = 0.1s;
+			set beresp.grace = 0s;
+			set beresp.keep = 60s;
+		}
+	}
+} -start
+
+varnish v1 -cliok "param.set debug +syncvsl"
+
+# This client gets a streaming failing result from s1
+client c1 {
+	txreq -hdr "Client: c1"
+	rxresphdrs
+	expect resp.status == 200
+	expect resp.http.transfer-encoding == "chunked"
+} -start
+
+delay 1
+
+# This client gets a streaming failing result from s1 through
+# IMS update by s2
+client c2 {
+	txreq -hdr "Client: c2"
+	sema r1 sync 3
+	rxresphdrs
+	expect resp.status == 200
+	expect resp.http.transfer-encoding == "chunked"
+} -run
+
+delay 1
+
+# This client should get a fresh fetch from s3
+client c3 {
+	txreq -hdr "Client: c3"
+	rxresp
+	expect resp.status == 200
+	expect resp.body == "abcdef"
+} -run



More information about the varnish-commit mailing list