[4.0] 51cee0b 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.

Lasse Karstensen lkarsten at varnish-software.com
Mon Jan 19 16:21:20 CET 2015


commit 51cee0bff0072ef2d2b39be77b92f475694540d4
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Tue Nov 18 13:58:29 2014 +0100

    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
    
    (cherry picked from commit 969674dcb3b4d430a38b7f1b1e41199b25cc8491)

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 9478edc..18c937d 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -952,9 +952,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_obj != NULL)
+			(void)HSH_DerefObj(&wrk->stats, &bo->ims_obj);
+		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 f93a86f..02e051c 100644
--- a/include/tbl/vsc_f_main.h
+++ b/include/tbl/vsc_f_main.h
@@ -237,8 +237,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