Skip to content

Commit

Permalink
condfetch: Demote to fetch for dying stale_oc
Browse files Browse the repository at this point in the history
  • Loading branch information
dridi committed Mar 13, 2024
1 parent 52f16cf commit cc56c8b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/varnishd/cache/cache_fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ vbf_stp_mkbereq(struct worker *wrk, struct busyobj *bo)
}
http_ForceField(bo->bereq0, HTTP_HDR_PROTO, "HTTP/1.1");

if (bo->stale_oc != NULL &&
if (bo->stale_oc != NULL && !(bo->stale_oc->flags & OC_F_DYING) &&
ObjCheckFlag(bo->wrk, bo->stale_oc, OF_IMSCAND) &&
(bo->stale_oc->boc != NULL || ObjGetLen(wrk, bo->stale_oc) != 0)) {
AZ(bo->stale_oc->flags & (OC_F_HFM|OC_F_PRIVATE));
Expand Down
59 changes: 59 additions & 0 deletions bin/varnishtest/tests/c00130.vtc
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
varnishtest "Demote condfetch to fetch on invalidated stale object"

barrier b1 sock 2
barrier b2 sock 2

server s1 {
rxreq
txresp -hdr {ETag: "foo"} -body corrupted

rxreq
expect req.http.If-None-Match == <undef>
txresp -hdr {ETag: "foo"} -body valid
} -start

varnish v1 -vcl+backend {
import vtc;
sub vcl_recv {
if (req.method == "PURGE") {
return (purge);
}
}
sub vcl_miss {
if (req.http.sync) {
vtc.barrier_sync("${b1_sock}");
vtc.barrier_sync("${b2_sock}");
}
}
sub vcl_backend_response {
set beresp.ttl = 1ms;
set beresp.grace = 0s;
set beresp.keep = 10s;
}
sub vcl_deliver {
set resp.http.obj-hits = obj.hits;
}
} -start

client c1 {
txreq
rxresp
expect resp.body == corrupted
expect resp.http.obj-hits == 0

delay 0.1

txreq -hdr "sync: true"
rxresp
expect resp.body == valid
expect resp.http.obj-hits == 0
} -start

barrier b1 sync
client c2 {
txreq -req PURGE
rxresp
} -run
barrier b2 sync

client c1 -wait

0 comments on commit cc56c8b

Please sign in to comment.