Mailing List Archive

[6.0] ee991059c vbf_stp_condfetch: handle storage error instead of crashing
commit ee991059c92a2ea1c473effcb4f303137f60eacd
Author: Emanuele Rocca <ema@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 c3ff67e9a..f7fd60424 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -737,7 +737,13 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
}
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");
+ bo->htc->doclose = SC_RX_BODY;
+ VFP_Close(bo->vfc);
+ VDI_Finish(bo->wrk, bo);
+ return (F_STP_ERROR);
+ }

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
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit