[4.1] 8ba2781 On fetch failure, make the vcl_backend_error{} object cacheable for 5 seconds if there is a waiting list.

Lasse Karstensen lkarsten at varnish-software.com
Thu Jan 14 15:15:11 CET 2016


commit 8ba2781e72ceb4ce6046e74a239094931f1b1b88
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Jan 6 18:57:31 2016 +0000

    On fetch failure, make the vcl_backend_error{} object cacheable
    for 5 seconds if there is a waiting list.
    
    This allows the waiting list to drain (returning 503) quickly,
    rather than one by one trying to pester the backend and only
    giving up after the connect_timeout.
    
    Related to: #1823

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index cd64257..3d0517c 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -793,8 +793,22 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
 	http_TimeHeader(bo->beresp, "Date: ", now);
 	http_SetHeader(bo->beresp, "Server: Varnish");
 
-	EXP_Clr(&bo->fetch_objcore->exp);
-	bo->fetch_objcore->exp.t_origin = bo->t_prev;
+	if (bo->fetch_objcore->objhead->waitinglist != NULL) {
+		/*
+		 * If there is a waitinglist, it means that there is no
+		 * grace-able object, so cache the error return for a
+		 * short time, so the waiting list can drain, rather than
+		 * each objcore on the waiting list sequentially attempt
+		 * to fetch from the backend.
+		 */
+		bo->fetch_objcore->exp.t_origin = now;
+		bo->fetch_objcore->exp.ttl = 1;
+		bo->fetch_objcore->exp.grace = 5;
+		bo->fetch_objcore->exp.keep = 5;
+	} else {
+		EXP_Clr(&bo->fetch_objcore->exp);
+		bo->fetch_objcore->exp.t_origin = now;
+	}
 
 	synth_body = VSB_new_auto();
 	AN(synth_body);



More information about the varnish-commit mailing list