Commit af7ef471 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

condfetch: Handle failed stale_oc without a boc

The assertion that the stale objcore of a conditional fetch cannot be
failed unless it was streaming is incorrect. Between the moment when
we grab the stale objcore in HSH_Lookup and the moment we try to use
it after vcl_backend_response, the backend fetch may have completed or
failed.

Instead, we need to treat an ongoing fetch and a failed fetch as
separate checks since the latter may happen with or without a boc.
parent 5dd19c0d
......@@ -800,14 +800,18 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
HSH_DerefBoc(bo->wrk, stale_oc);
stale_boc = NULL;
if (stale_state != BOS_FINISHED) {
(void)VFP_Error(bo->vfc, "Template object failed");
vbf_cleanup(bo);
wrk->stats->fetch_failed++;
return (F_STP_FAIL);
assert(stale_state == BOS_FAILED);
AN(stale_oc->flags & OC_F_FAILED);
}
}
AZ(stale_boc);
AZ(stale_oc->flags & OC_F_FAILED);
if (stale_oc->flags & OC_F_FAILED) {
(void)VFP_Error(bo->vfc, "Template object failed");
vbf_cleanup(bo);
wrk->stats->fetch_failed++;
return (F_STP_FAIL);
}
if (vbf_beresp2obj(bo)) {
vbf_cleanup(bo);
......
varnishtest "Failed post-streaming revalidation"
barrier b1 cond 2
barrier b2 sock 2
barrier b3 sock 2
server s1 {
rxreq
txresp -nolen -hdr {Etag: "abc"} -hdr "Content-Length: 100"
barrier b1 sync
barrier b2 sync
} -start
server s2 {
rxreq
expect req.http.If-None-Match == {"abc"}
txresp -status 304 -nolen -hdr {Etag: "abc"} -hdr "Content-Length: 100"
} -start
varnish v1 -vcl+backend {
import directors;
import vtc;
sub vcl_recv {
if (req.http.backend == "s2") {
set req.backend_hint = s2;
}
}
sub vcl_backend_response {
if (beresp.was_304) {
vtc.barrier_sync("${b2_sock}");
vtc.barrier_sync("${b3_sock}");
}
set beresp.ttl = 1ms;
}
} -start
client c1 {
txreq -hdr "backend: s1"
rxresphdrs
expect resp.status == 200
expect_close
} -start
barrier b1 sync
# ensure stale_oc
delay 0.01
client c2 {
txreq -hdr "backend: s2"
rxresphdrs
expect resp.status == 200
expect_close
} -start
client c1 -wait
barrier b3 sync
client c2 -wait
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment