Commit fe7b3f17 authored by Kristian Lyngstøl's avatar Kristian Lyngstøl

Use a graced object if a backend is unhealthy


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3886 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 4d37a9f2
......@@ -67,6 +67,7 @@
#include "stevedore.h"
#include "hash_slinger.h"
#include "vsha256.h"
#include "cache_backend.h"
static const struct hash_slinger *hash;
unsigned save_hash;
......@@ -362,6 +363,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(sp->http, HTTP_MAGIC);
CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC);
AN(hash);
w = sp->wrk;
......@@ -419,14 +421,16 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
}
/*
* If we have seen a busy object, and have an object in grace,
* use it, if req.grace is also satisified.
* If we have seen a busy object or the backend is unhealthy, and
* have an object in grace, use it, if req.grace is also
* satisified.
* XXX: Interesting footnote: The busy object might be for a
* XXX: different "Vary:" than we sought. We have no way of knowing
* XXX: this until the object is unbusy'ed, so in practice we
* XXX: serialize fetch of all Vary's if grace is possible.
*/
if (oc == NULL && grace_oc != NULL && busy_oc != NULL) {
if (oc == NULL && grace_oc != NULL &&
(busy_oc != NULL || !sp->director->healthy(sp))) {
o = grace_oc->obj;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
if (o->ttl + HSH_Grace(sp->grace) >= sp->t_req)
......
# $Id$
test "Check grace with sick backends"
server s1 -listen 127.0.0.1:9080 -repeat 4 {
rxreq
expect req.url == "/"
txresp -body "hi"
} -start
varnish v1 -vcl {
backend b {
.host = "127.0.0.1";
.port = "9080";
.probe = {
.url = "/";
.timeout = 30ms;
.interval = 1s;
.window = 2;
.threshold = 1;
}
}
sub vcl_fetch {
set beresp.ttl = 1s;
set beresp.grace = 1m;
set beresp.cacheable = true;
}
} -start
delay 2
client c1 {
txreq -url "/"
rxresp
expect resp.status == 200
} -run
delay 3
client c2 {
txreq -url "/"
rxresp
expect resp.status == 200
} -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