[master] d3b6409ea vbf_stp_condfetch: handle storage error instead of crashing

Nils Goroll nils.goroll at uplex.de
Fri Apr 3 17:22:07 UTC 2020


commit d3b6409ea3f52851aa63fde8120af5cfc430db8b
Author: Emanuele Rocca <ema at wikimedia.org>
Date:   Fri Apr 3 17:10:22 2020 +0200

    vbf_stp_condfetch: handle storage error instead of crashing
    
    Fixes: #3273

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index f911f7ca7..036108954 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -733,7 +733,12 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 	AZ(stale_boc);
 	AZ(bo->stale_oc->flags & OC_F_FAILED);
 
-	AZ(vbf_beresp2obj(bo));
+	if (vbf_beresp2obj(bo)) {
+		(void)VFP_Error(bo->vfc, "Could not get storage in vbf_stp_condfetch");
+		vbf_cleanup(bo);
+		wrk->stats->fetch_failed++;
+		return (F_STP_FAIL);
+	}
 
 	if (ObjHasAttr(bo->wrk, bo->stale_oc, OA_ESIDATA))
 		AZ(ObjCopyAttr(bo->wrk, bo->fetch_objcore, bo->stale_oc,
diff --git a/bin/varnishtest/tests/v00064.vtc b/bin/varnishtest/tests/v00064.vtc
new file mode 100644
index 000000000..8a608e38e
--- /dev/null
+++ b/bin/varnishtest/tests/v00064.vtc
@@ -0,0 +1,66 @@
+varnishtest "vbf_stp_condfetch could not get storage #3273"
+
+server s1 {
+    rxreq
+    expect req.url == "/transient"
+    txresp -bodylen 1048400
+
+    rxreq
+    expect req.url == "/malloc"
+    txresp -hdr "Cache-Control: max-age=2" -hdr "Last-Modified: Fri, 03 Apr 2020 13:00:01 GMT" -bodylen 1048300
+
+    rxreq
+    expect req.http.If-Modified-Since == "Fri, 03 Apr 2020 13:00:01 GMT"
+    expect req.url == "/malloc"
+    txresp -status 304
+} -start
+
+varnish v1 \
+ -arg "-s Transient=default,1m" \
+ -arg "-s malloc,1m" \
+ -arg "-p nuke_limit=0" \
+ -syntax 4.0 \
+ -vcl+backend {
+    sub vcl_backend_response {
+        if (bereq.url == "/transient") {
+            set beresp.storage = storage.Transient;
+            # Unset Date header to not change the object sizes
+            unset beresp.http.Date;
+        }
+    }
+} -start
+
+varnish v1 -cliok "param.set debug +syncvsl"
+
+delay .1
+
+client c1 {
+    # Fill transient
+    txreq -url "/transient"
+    rxresp
+    expect resp.status == 200
+} -run
+
+delay .1
+
+varnish v1 -expect SM?.Transient.g_bytes > 1048000
+varnish v1 -expect SM?.Transient.g_space == 8
+
+client c1 {
+    # Fill malloc
+    txreq -url "/malloc" -hdr "If-Modified-Since: Fri, 03 Apr 2020 12:00:01 GMT"
+    rxresp
+    expect resp.status == 200
+
+    delay 3
+} -run
+
+varnish v1 -expect SM?.s0.g_bytes > 1048000
+varnish v1 -expect SM?.s0.g_space == 4
+
+client c1 {
+    # Check that Varnish is still alive
+    txreq -url "/malloc" -hdr "If-Modified-Since: Fri, 03 Apr 2020 12:00:01 GMT"
+    rxresp
+    expect resp.status == 200
+} -run


More information about the varnish-commit mailing list