[master] 969674d Don't attempt to run the fetch in the request thread if there are no threads available in the pool, fail the fetch and count it.

Poul-Henning Kamp phk at FreeBSD.org
Mon Nov 3 11:34:41 CET 2014


commit 969674dcb3b4d430a38b7f1b1e41199b25cc8491
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Nov 3 10:34:31 2014 +0000

    Don't attempt to run the fetch in the request thread if there are
    no threads available in the pool, fail the fetch and count it.
    
    Fixes #1620
    Fixes #1621

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index e83d06d..f9cf52c 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -957,9 +957,13 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc,
 	bo->fetch_task.priv = bo;
 	bo->fetch_task.func = vbf_fetch_thread;
 
-	if (Pool_Task(wrk->pool, &bo->fetch_task, POOL_QUEUE_FRONT))
-		vbf_fetch_thread(wrk, bo);
-	if (mode == VBF_BACKGROUND) {
+	if (Pool_Task(wrk->pool, &bo->fetch_task, POOL_QUEUE_FRONT)) {
+		wrk->stats->fetch_no_thread++;
+		(void)vbf_stp_fail(req->wrk, bo);
+		if (bo->ims_oc != NULL)
+			(void)HSH_DerefObjCore(wrk, &bo->ims_oc);
+		VBO_DerefBusyObj(wrk, &bo);
+	} else if (mode == VBF_BACKGROUND) {
 		VBO_waitstate(bo, BOS_REQ_DONE);
 	} else {
 		VBO_waitstate(bo, BOS_STREAM);
diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h
index f714e33..5b0c52d 100644
--- a/include/tbl/vsc_f_main.h
+++ b/include/tbl/vsc_f_main.h
@@ -228,8 +228,12 @@ VSC_F(fetch_304,		uint64_t, 1, 'c', info,
 	"beresp with no body because of 304 response."
 )
 VSC_F(fetch_failed,		uint64_t, 1, 'c', info,
-    "Fetch body failed",
-	"beresp body fetch failed."
+    "Fetch failed (all causes)",
+	"beresp fetch failed."
+)
+VSC_F(fetch_no_thread,		uint64_t, 1, 'c', info,
+    "Fetch failed (no thread)",
+	"beresp fetch failed, no thread available."
 )
 
 /*---------------------------------------------------------------------



More information about the varnish-commit mailing list