[master] 3f4cd92 sess_fail_* detailled accept error counters

Nils Goroll nils.goroll at uplex.de
Mon May 28 14:08:13 UTC 2018


commit 3f4cd9297d53b1e18e594c83d9fd068d4dd4a666
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon May 28 16:07:27 2018 +0200

    sess_fail_* detailled accept error counters
    
    We already emitted Debug log records for accept failures, but for
    all practical purposes this is useless for forensics.
    
    These counters will point directly to the root cause for the most
    common issues with sess_fail (accept failures). sess_fail is preserved
    as an overall counter as it will most likely be already monitored for
    many installations.
    
    Ref	#2622

diff --git a/bin/varnishd/VSC_main.vsc b/bin/varnishd/VSC_main.vsc
index a2e2d01..dbcbcdf 100644
--- a/bin/varnishd/VSC_main.vsc
+++ b/bin/varnishd/VSC_main.vsc
@@ -33,9 +33,46 @@
 .. varnish_vsc:: sess_fail
 	:oneliner:	Session accept failures
 
-	Count of failures to accept TCP connection.  Either the client
-	changed its mind, or the kernel ran out of some resource like file
-	descriptors.
+	Count of failures to accept TCP connection.
+
+	This counter is the sum of the sess_fail_* counters, which
+	give more detailled information.
+
+.. varnish_vsc:: sess_fail_econnaborted
+	:oneliner:	Session accept failures: connection aborted
+
+	Detailled reason for sess_fail: Connection aborted by the
+	client, usually harmless.
+
+.. varnish_vsc:: sess_fail_eintr
+	:oneliner:	Session accept failures: interrupted system call
+
+	Detailled reason for sess_fail: The accept() call was
+	interrupted, usually harmless
+
+.. varnish_vsc:: sess_fail_emfile
+	:oneliner:	Session accept failures: too many open files
+
+	Detailled reason for sess_fail: No file descriptor was
+	available. Consider raising RLIMIT_NOFILE (see ulimit -n).
+
+.. varnish_vsc:: sess_fail_ebadf
+	:oneliner:	Session accept failures: bad file descriptor
+
+	Detailled reason for sess_fail: The listen socket file
+	descriptor was invalid. Should never happen.
+
+.. varnish_vsc:: sess_fail_enomem
+	:oneliner:	Session accept failures: not enough memory
+
+	Detailled reason for sess_fail: Most likely insufficient
+	socket buffer memory. Should never happen
+
+.. varnish_vsc:: sess_fail_other
+	:oneliner:	Session accept failures: other
+
+	Detailled reason for sess_fail: neither of the above, see
+	Debug log (varnishlog -g raw -I Debug:^Accept).
 
 .. varnish_vsc:: client_req_400
 	:oneliner:	Client requests received, subject to 400 errors
diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index 6973d01..455697f 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -489,23 +489,32 @@ vca_accept_task(struct worker *wrk, void *arg)
 		if (i < 0) {
 			switch (errno) {
 			case ECONNABORTED:
+				wrk->stats->sess_fail_econnaborted++;
+				break;
+			case EINTR:
+				wrk->stats->sess_fail_eintr++;
 				break;
 			case EMFILE:
-				VSL(SLT_Debug, ls->sock, "Too many open files");
+				wrk->stats->sess_fail_emfile++;
 				vca_pace_bad();
 				break;
 			case EBADF:
-				VSL(SLT_Debug, ls->sock, "Accept failed: %s",
-				    strerror(errno));
+				wrk->stats->sess_fail_ebadf++;
+				vca_pace_bad();
+				break;
+			case ENOBUFS:
+			case ENOMEM:
+				wrk->stats->sess_fail_enomem++;
 				vca_pace_bad();
 				break;
 			default:
-				VSL(SLT_Debug, ls->sock, "Accept failed: %s",
-				    strerror(errno));
+				wrk->stats->sess_fail_other++;
 				vca_pace_bad();
 				break;
 			}
 			wrk->stats->sess_fail++;
+			VSL(SLT_Debug, ls->sock, "Accept failed: %s",
+			    strerror(errno));
 			(void)Pool_TrySumstat(wrk);
 			continue;
 		}
diff --git a/doc/changes.rst b/doc/changes.rst
index c1e996f..97ce466 100644
--- a/doc/changes.rst
+++ b/doc/changes.rst
@@ -37,6 +37,20 @@ varnishadm
 * The output format of the ``backend.list`` CLI command has been
   changed.
 
+varnishstat
+-----------
+
+* The counters
+
+  * ``sess_fail_econnaborted``
+  * ``sess_fail_eintr``
+  * ``sess_fail_emfile``
+  * ``sess_fail_ebadf``
+  * ``sess_fail_enomem``
+  * ``sess_fail_other``
+
+  now break down the detailled reason for session accept failures, the
+  sum of which continues to be counted in ``sess_fail``.
 
 VCL and bundled VMODs
 ---------------------


More information about the varnish-commit mailing list