Commit 3f56d4eb authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Fix ttl when backend fetches are salvaged into transient storage.

Submitted by:	Martin
Fixes		#1140
parent f289def3
......@@ -812,12 +812,12 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req)
* Try to salvage the transaction by allocating a
* shortlived object on Transient storage.
*/
req->obj = STV_NewObject(bo, &req->objcore, TRANSIENT_STORAGE,
l, nhttp);
if (bo->exp.ttl > cache_param->shortlived)
bo->exp.ttl = cache_param->shortlived;
bo->exp.grace = 0.0;
bo->exp.keep = 0.0;
req->obj = STV_NewObject(bo, &req->objcore, TRANSIENT_STORAGE,
l, nhttp);
}
bo->stats = NULL;
if (req->obj == NULL) {
......
varnishtest "Transient-salvaged objects ttl should be shortened - #1140"
server s1 {
# This response should almost completely fill the storage
rxreq
expect req.url == /url1
txresp -bodylen 1048050
# The next one should not fit in the storage, ending up in transient
# with zero ttl (=shortlived)
rxreq
expect req.url == /url2
txresp -bodylen 1024
# And therefore this one should be fetched next
rxreq
expect req.url == /url2
txresp -bodylen 1025
} -start
varnish v1 -arg "-p expiry_sleep=0.01 -p nuke_limit=0 -p shortlived=0" \
-storage "-smalloc,1m" -vcl+backend { } -start
client c1 {
txreq -url /url1
rxresp
expect resp.status == 200
expect resp.bodylen == 1048050
txreq -url /url2
rxresp
expect resp.status == 200
expect resp.bodylen == 1024
txreq -url /url2
rxresp
expect resp.status == 200
expect resp.bodylen == 1025
} -run
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