Skip to content
Permalink
Browse files

Don't ignore OA_GZIPBITS if there is a boc

Under load, client c4 from g00005.vtc may fail with a 200 response
instead of the expected 206 partial response.

There is a window during which we might still see a boc, but because
c4 sets beresp.do_stream to false, the fetch has to be over. To close
this race we can instead reference the boc as suggested in #2904 and
keep track of the boc state.
  • Loading branch information
Dridi committed Jan 10, 2020
1 parent 8ea006e commit f82b5f150f2a9aa92ac38665d90082cc51aeb2d8
Showing with 15 additions and 5 deletions.
  1. +11 −1 bin/varnishd/cache/cache_gzip.c
  2. +4 −4 bin/varnishtest/tests/g00005.vtc
@@ -42,6 +42,7 @@

#include "cache_varnishd.h"
#include "cache_filter.h"
#include "cache_objhead.h"
#include "cache_vgz.h"
#include "vend.h"

@@ -288,6 +289,8 @@ static int v_matchproto_(vdp_init_f)
vdp_gunzip_init(struct req *req, void **priv)
{
struct vgz *vg;
struct boc *boc;
enum boc_state_e bos;
const char *p;
ssize_t dl;
uint64_t u;
@@ -309,8 +312,15 @@ vdp_gunzip_init(struct req *req, void **priv)

req->resp_len = -1;

boc = HSH_RefBoc(req->objcore);
if (boc != NULL) {
bos = boc->state;
HSH_DerefBoc(req->wrk, req->objcore);
} else
bos = BOS_FINISHED;

/* OA_GZIPBITS is not stable yet */
if (req->objcore->boc)
if (bos < BOS_FINISHED)
return (0);

p = ObjGetAttr(req->wrk, req->objcore, OA_GZIPBITS, &dl);
@@ -35,7 +35,7 @@ client c1 {

varnish v1 -vsl_catchup

client c1 {
client c2 {
txreq -hdr "Accept-encoding: gzip;q=0.1"
rxresp
expect resp.http.content-encoding == "gzip"
@@ -49,7 +49,7 @@ varnish v1 -vsl_catchup
# is completed before we attempt the range request
delay 2

client c1 {
client c3 {
txreq -hdr "Range: bytes=3-5"
rxresp
expect resp.status == 206
@@ -60,7 +60,7 @@ client c1 {

varnish v1 -vsl_catchup

client c1 {
client c4 {
txreq -url "/nostreamcachemiss" -hdr "Range: bytes=3-5"
rxresp
expect resp.status == 206
@@ -71,7 +71,7 @@ client c1 {

varnish v1 -vsl_catchup

client c1 {
client c5 {
# simple cache miss, no stream, no gunzip
txreq -url "/nostream2" -hdr "Range: bytes=3-5" -hdr "Accept-Encoding: gzip"
rxresp

0 comments on commit f82b5f1

Please sign in to comment.
You can’t perform that action at this time.