
phk at varnish-cache
Jul 31, 2012, 1:06 AM
Post #1 of 1
(41 views)
Permalink
|
|
[master] feac371 Don't do automatic backend retry if we have received anything from the backend at all. The retry is only (pseudo-)valid when we have not received anything at all, indicating that the backend closed before it got our request.
|
|
commit feac37150e5820cb36b0181811a47b957cd9b51c Author: Poul-Henning Kamp <phk [at] FreeBSD> Date: Tue Jul 31 08:04:15 2012 +0000 Don't do automatic backend retry if we have received anything from the backend at all. The retry is only (pseudo-)valid when we have not received anything at all, indicating that the backend closed before it got our request. Also don't retry if we sent the request body (not part of test-case). Fixes #1156 diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 3b9b08d..1d97c51 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -480,6 +480,8 @@ FetchHdr(struct req *req, int need_host_hdr, int sendbody) /* Deal with any message-body the request might have */ i = FetchReqBody(req, sendbody); + if (sendbody && req->reqbodydone) + retry = -1; if (WRW_FlushRelease(wrk) || i > 0) { VSLb(req->vsl, SLT_FetchError, "backend write error: %d (%s)", @@ -520,6 +522,7 @@ FetchHdr(struct req *req, int need_host_hdr, int sendbody) return (retry); } if (first) { + retry = -1; first = 0; VTCP_set_read_timeout(vc->fd, vc->between_bytes_timeout); diff --git a/bin/varnishtest/tests/r01156.vtc b/bin/varnishtest/tests/r01156.vtc new file mode 100644 index 0000000..2624ddd --- /dev/null +++ b/bin/varnishtest/tests/r01156.vtc @@ -0,0 +1,53 @@ +varnishtest "Don't retry if backend ever sent anything" + +server s1 { + rxreq + expect req.url == /1 + txresp -bodylen 1 + + rxreq + expect req.url == /2 + close + accept + + rxreq + expect req.url == /2 + txresp -bodylen 2 + + rxreq + expect req.url == /3 + send "200 " + delay .1 + close + accept + + rxreq + expect req.url == /4 + txresp -bodylen 4 +} -start + +varnish v1 -vcl+backend {} -start + +client c1 { + txreq -url /1 + rxresp + expect resp.status == 200 + expect resp.bodylen == 1 + + # This one should get retried + txreq -url /2 + rxresp + expect resp.status == 200 + expect resp.bodylen == 2 + + # This one should not get retried + txreq -url /3 + rxresp + expect resp.status == 503 +} -run +client c1 { + txreq -url /4 + rxresp + expect resp.status == 200 + expect resp.bodylen == 4 +} -run _______________________________________________ varnish-commit mailing list varnish-commit [at] varnish-cache https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit
|