[master] a43326d Rearm at zero TTL on failed objects
Martin Blix Grydeland
martin at varnish-software.com
Tue Apr 8 11:03:27 CEST 2014
commit a43326dd93b9a37428b9aecf72e785ed7675afef
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Tue Apr 1 13:47:43 2014 +0200
Rearm at zero TTL on failed objects
Fixes: #1468
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 54a042d..19b8fb8 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -707,6 +707,11 @@ vbf_stp_fail(struct worker *wrk, struct busyobj *bo)
assert(bo->state < BOS_FINISHED);
HSH_Fail(bo->fetch_objcore);
+ if (bo->fetch_objcore->exp_flags & OC_EF_EXP) {
+ /* Already unbusied - expire it */
+ AN(bo->fetch_obj);
+ EXP_Rearm(bo->fetch_obj, bo->fetch_obj->exp.t_origin, 0, 0, 0);
+ }
wrk->stats.fetch_failed++;
VBO_setstate(bo, BOS_FAILED);
return (F_STP_DONE);
diff --git a/bin/varnishtest/tests/r01468.vtc b/bin/varnishtest/tests/r01468.vtc
new file mode 100644
index 0000000..119c1da
--- /dev/null
+++ b/bin/varnishtest/tests/r01468.vtc
@@ -0,0 +1,53 @@
+varnishtest "#1468 - freeing failed obj"
+
+server s1 {
+ rxreq
+ expect req.url == "/1"
+ txresp -nolen -hdr "Transfer-Encoding: chunked"
+ chunked {<HTML>}
+ sema r1 sync 2
+ close
+
+ accept
+ rxreq
+ expect req.url == "/2"
+ txresp -nolen -hdr "Transfer-Encoding: chunked"
+ chunked {<HTML>}
+ sema r1 sync 2
+} -start
+
+varnish v1 -vcl+backend {
+ sub vcl_recv {
+ if (req.url == "/2") {
+ return (pass);
+ }
+ }
+ sub vcl_backend_response {
+ set beresp.ttl = 5m;
+ }
+} -start
+
+# Test the regular cached content case
+client c1 {
+ txreq -url "/1"
+ rxresphdrs
+ expect resp.status == 200
+ rxchunk
+ sema r1 sync 2
+ expect_close
+} -run
+
+# Test the pass from vcl_recv case
+client c1 {
+ txreq -url "/2"
+ rxresphdrs
+ expect resp.status == 200
+ rxchunk
+ sema r1 sync 2
+ expect_close
+} -run
+
+# Delay to allow expiry thread to do it's job
+delay 1
+
+varnish v1 -expect n_object == 0
More information about the varnish-commit
mailing list