Remove our artificial PG_SOMAXCONN limit on listen queue length.
authorTom Lane <[email protected]>
Tue, 23 Aug 2022 14:14:45 +0000 (10:14 -0400)
committerTom Lane <[email protected]>
Tue, 23 Aug 2022 14:15:06 +0000 (10:15 -0400)
I added this in commit 153f40067, out of paranoia about kernels
possibly rejecting very large listen backlog requests.  However,
POSIX has said for decades that the kernel must silently reduce
any value it considers too large, and there's no evidence that
any current system doesn't obey that.  Let's just drop this limit
and save some complication.

While we're here, compute the request as twice MaxConnections not
twice MaxBackends; the latter no longer means what it did in 2001.

Per discussion of a report from Kevin McKibbin.

Discussion: https://postgr.es/m/CADc_NKg2d+oZY9mg4DdQdoUcGzN2kOYXBu-3--RW_hEe0tUV=g@mail.gmail.com

src/backend/libpq/pqcomm.c
src/include/pg_config_manual.h

index 8ff3be611deab7c5355ad2542527e61cb6a2e7ef..7112e9751b17b5c23ccf9ea598de4ce6911c72b8 100644 (file)
@@ -537,13 +537,11 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
                }
 
                /*
-                * Select appropriate accept-queue length limit.  PG_SOMAXCONN is only
-                * intended to provide a clamp on the request on platforms where an
-                * overly large request provokes a kernel error (are there any?).
+                * Select appropriate accept-queue length limit.  It seems reasonable
+                * to use a value similar to the maximum number of child processes
+                * that the postmaster will permit.
                 */
-               maxconn = MaxBackends * 2;
-               if (maxconn > PG_SOMAXCONN)
-                       maxconn = PG_SOMAXCONN;
+               maxconn = MaxConnections * 2;
 
                err = listen(fd, maxconn);
                if (err < 0)
index 844c3e0f0943386ac034f810c285a614efb5ef6f..f2a106f983dbbc03646f3618ca1fd7de1f9da57a 100644 (file)
  */
 #define MAXPGPATH              1024
 
-/*
- * PG_SOMAXCONN: maximum accept-queue length limit passed to
- * listen(2).  You'd think we should use SOMAXCONN from
- * <sys/socket.h>, but on many systems that symbol is much smaller
- * than the kernel's actual limit.  In any case, this symbol need be
- * twiddled only if you have a kernel that refuses large limit values,
- * rather than silently reducing the value to what it can handle
- * (which is what most if not all Unixen do).
- */
-#define PG_SOMAXCONN   10000
-
 /*
  * You can try changing this if you have a machine with bytes of
  * another size, but no guarantee...