[Varnish] #1500: Possible bug in 4.0.0 with Range+do_stream=true
Varnish
varnish-bugs at varnish-cache.org
Sat May 10 18:40:25 CEST 2014
#1500: Possible bug in 4.0.0 with Range+do_stream=true
-------------------------+--------------------
Reporter: moseleymark | Type: defect
Status: new | Priority: normal
Milestone: | Component: build
Version: 4.0.0 | Severity: normal
Keywords: |
-------------------------+--------------------
I noticed in testing Range requests (to an Apache 2.2 backend, Ubuntu
Precise 64-bit) that in sufficiently large requests, Range requests on
*uncached* content were often returning 200s with the full content. The
larger the request, the more likely it was that this would happen. See
https://www.varnish-cache.org/comment/1654#comment-1654 for details on
some testing I did.
In the VCL below, if I uncomment the do_stream=false, I seem to get 206s
on uncached large files every time. I need to test this further, but so
far, with it commented out (since I guess do_stream is true by default
now), on a 10meg file, I was getting 200s on uncached content almost 100%
of the time; with it uncommented, I haven't seen a 200 yet.
Dropping in some debugging statements, it looks like that for streaming
large-ish files, this 'if' statement in v1d_dorange
(bin/varnishd/cache/cache_http1_deliver.c, about line 105 or so) fails:
if (low >= req->obj->len)
return;
because req->obj->len is 0. I'm guessing that with a big enough file,
streaming causes v1d_dorange to get called before len gets set to non-
zero, since it's still downloading the file from the backend (which
considering how streaming works, kind of makes sense).
Without streaming (this is my debug statement, via varnishlog):
- Debug "IN v1d_dorange 3: low=1, len=10240000"
With streaming:
- Debug "IN v1d_dorange 3: low=1, len=0"
I'm still trying to trace why req->obj->len would be 0 in this case. I'm
not a C guy, so I couldn't even begin to offer a patch that wouldn't make
your eyes bleed :)
Testcase is just using a very stripped down VCL:
{{{
vcl 4.0;
import std;
backend test_http {
.host = "127.0.0.1";
.port = "80";
}
sub vcl_backend_response {
# Commented, I get 200s; uncommented, I get 206s
# set beresp.do_stream = false;
return( deliver );
}
sub vcl_recv {
# Set backend dynamically
set req.backend_hint = test_http;
# Default action is to look up object in cache
return( hash );
}
}}}
--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1500>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator
More information about the varnish-bugs
mailing list