Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0f47457

Browse files
committed
Remove our artificial PG_SOMAXCONN limit on listen queue length.
I added this in commit 153f400, 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
1 parent ba94dfd commit 0f47457

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

src/backend/libpq/pqcomm.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -537,13 +537,11 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
537537
}
538538

539539
/*
540-
* Select appropriate accept-queue length limit. PG_SOMAXCONN is only
541-
* intended to provide a clamp on the request on platforms where an
542-
* overly large request provokes a kernel error (are there any?).
540+
* Select appropriate accept-queue length limit. It seems reasonable
541+
* to use a value similar to the maximum number of child processes
542+
* that the postmaster will permit.
543543
*/
544-
maxconn = MaxBackends * 2;
545-
if (maxconn > PG_SOMAXCONN)
546-
maxconn = PG_SOMAXCONN;
544+
maxconn = MaxConnections * 2;
547545

548546
err = listen(fd, maxconn);
549547
if (err < 0)

src/include/pg_config_manual.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,6 @@
114114
*/
115115
#define MAXPGPATH 1024
116116

117-
/*
118-
* PG_SOMAXCONN: maximum accept-queue length limit passed to
119-
* listen(2). You'd think we should use SOMAXCONN from
120-
* <sys/socket.h>, but on many systems that symbol is much smaller
121-
* than the kernel's actual limit. In any case, this symbol need be
122-
* twiddled only if you have a kernel that refuses large limit values,
123-
* rather than silently reducing the value to what it can handle
124-
* (which is what most if not all Unixen do).
125-
*/
126-
#define PG_SOMAXCONN 10000
127-
128117
/*
129118
* You can try changing this if you have a machine with bytes of
130119
* another size, but no guarantee...

0 commit comments

Comments
 (0)