r3988 - in branches/2.0/varnish-cache/bin: varnishd varnishtest/tests

tfheen at projects.linpro.no tfheen at projects.linpro.no
Mon Mar 23 13:10:23 CET 2009


Author: tfheen
Date: 2009-03-23 13:10:23 +0100 (Mon, 23 Mar 2009)
New Revision: 3988

Added:
   branches/2.0/varnish-cache/bin/varnishtest/tests/s00002.vtc
Modified:
   branches/2.0/varnish-cache/bin/varnishd/cache_hash.c
Log:
Merge r3886: Use a graced object if a backend is unhealthy



Modified: branches/2.0/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_hash.c	2009-03-23 11:54:19 UTC (rev 3987)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_hash.c	2009-03-23 12:10:23 UTC (rev 3988)
@@ -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;
@@ -234,6 +235,7 @@
 	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;
 
@@ -281,11 +283,12 @@
 	}
 
 	/*
-	 * If we have a object in grace and being fetched,
-	 * 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.
 	 */
 	if (o == NULL && grace_o != NULL &&
-	    grace_o->child != NULL &&
+	    (grace_o->child != NULL || !sp->director->healthy(sp)) &&
 	    grace_o->ttl + HSH_Grace(sp->grace) >= sp->t_req)
 		o = grace_o;
 

Copied: branches/2.0/varnish-cache/bin/varnishtest/tests/s00002.vtc (from rev 3886, trunk/varnish-cache/bin/varnishtest/tests/s00002.vtc)
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/s00002.vtc	                        (rev 0)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/s00002.vtc	2009-03-23 12:10:23 UTC (rev 3988)
@@ -0,0 +1,44 @@
+# $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 obj.ttl = 1s; 
+		set obj.grace = 1m; 
+		set obj.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



More information about the varnish-commit mailing list