[master] be6949921 log accept failures under the SessError tag

Nils Goroll nils.goroll at uplex.de
Mon Sep 17 09:30:16 UTC 2018


commit be69499219db0704a136046369884531ee20bc01
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Sep 17 11:14:01 2018 +0200

    log accept failures under the SessError tag
    
    I consider it too late for a vtc, but this has been tested manually
    with ulimit -n 40. Example errors (tcp, uds)
    
             0 SessError      - a0 127.0.0.1 8080 3 24 Too many open files
             0 SessError      - a1 0.0.0.0 0 5 24 Too many open files

diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index 908613f47..2b920720a 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -451,6 +451,8 @@ vca_accept_task(struct worker *wrk, void *arg)
 	struct poolsock *ps;
 	struct listen_sock *ls;
 	int i;
+	char laddr[VTCP_ADDRBUFSIZE];
+	char lport[VTCP_PORTBUFSIZE];
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CAST_OBJ_NOTNULL(ps, arg, POOLSOCK_MAGIC);
@@ -510,9 +512,21 @@ vca_accept_task(struct worker *wrk, void *arg)
 				vca_pace_bad();
 				break;
 			}
+
+			i = errno;
 			wrk->stats->sess_fail++;
-			VSL(SLT_Debug, ls->sock, "Accept failed: %s",
-			    strerror(errno));
+
+			if (wa.acceptlsock->uds) {
+				strcpy(laddr, "0.0.0.0");
+				strcpy(lport, "0");
+			} else {
+				VTCP_myname(ls->sock, laddr, VTCP_ADDRBUFSIZE,
+				    lport, VTCP_ADDRBUFSIZE);
+			}
+
+			VSL(SLT_SessError, 0, "%s %s %s %d %d %s",
+			    wa.acceptlsock->name, laddr, lport,
+			    ls->sock, i, strerror(i));
 			(void)Pool_TrySumstat(wrk);
 			continue;
 		}
diff --git a/doc/sphinx/whats-new/upgrading-6.1.rst b/doc/sphinx/whats-new/upgrading-6.1.rst
index e70a0ddde..f6e53da1e 100644
--- a/doc/sphinx/whats-new/upgrading-6.1.rst
+++ b/doc/sphinx/whats-new/upgrading-6.1.rst
@@ -183,6 +183,12 @@ Other changes
     In particular, http connection (HTC) errors are now reported
     symbolically in addition to the previous numerical value.
 
+  * Log entries under the new ``SessError`` tag now give more
+    diagnostic information about session accept failures (failure to
+    accept a client connection). These must be viewed in raw grouping,
+    since accept failures are not part of any request/response
+    transaction.
+
   * When a backend is unhealthy, ``Backend_health`` now reports some
     diagnostic information in addition to the HTTP response and timing
     information.
diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h
index 6c74b4429..d682cf194 100644
--- a/include/tbl/vsl_tags.h
+++ b/include/tbl/vsl_tags.h
@@ -65,6 +65,20 @@ SLTM(CLI, 0, "CLI communication",
 
 /*---------------------------------------------------------------------*/
 
+SLTM(SessError, 0, "Client connection accept failed",
+	"Accepting a client connection has failed.\n\n"
+	"The format is::\n\n"
+	"\t%s %s %s %d %d %s\n"
+	"\t|  |  |  |  |  |\n"
+	"\t|  |  |  |  |  +- Detailed error message\n"
+	"\t|  |  |  |  +---- Error Number (errno) from accept(2)\n"
+	"\t|  |  |  +------- File descriptor number\n"
+	"\t|  |  +---------- Local TCP port\n"
+	"\t|  +------------- Local IPv4/6 address\n"
+	"\t+---------------- Socket name (from -a argument)\n"
+	"\n"
+)
+
 SLTM(SessOpen, 0, "Client connection opened",
 	"The first record for a client connection, with the socket-endpoints"
 	" of the connection.\n\n"


More information about the varnish-commit mailing list