Re: pgbench: could not connect to server: Resource temporarily unavailable
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Junwang Zhao <zhjwpku@gmail.com>
Cc: Thomas Munro <thomas.munro@gmail.com>,
Andrew Dunstan <andrew@dunslane.net>,
Kevin McKibbin <kevinmckibbin123@gmail.com>,
pgsql-performance@lists.postgresql.org
Date: 2022-08-23T03:37:43Z
Lists: pgsql-performance
Junwang Zhao <zhjwpku@gmail.com> writes:
> Just curious, *backlog* defines the maximum pending connections,
> why do we need to double the MaxConnections as the queue size?
The postmaster allows up to twice MaxConnections child processes
to exist, per the comment in canAcceptConnections:
* We allow more connections here than we can have backends because some
* might still be authenticating; they might fail auth, or some existing
* backend might exit before the auth cycle is completed. The exact
* MaxBackends limit is enforced when a new backend tries to join the
* shared-inval backend array.
You can argue that 2X might not be the right multiplier, and you
can argue that the optimal listen queue length might be more or
less than the limit on number of child processes, but that's how
we've historically done it. I'm not especially interested in
changing that without somebody making a well-reasoned case for
some other number.
regards, tom lane
Commits
-
Doc: document possible need to raise kernel's somaxconn limit.
- ba94dfd4c4f6 16.0 landed
- 1a9c3ffd6428 10.23 landed
- 04056e9268be 11.18 landed
- 7951e0d7af98 12.13 landed
- 3ccdeff7bf19 13.9 landed
- 04f1013be084 14.6 landed
- 2c63b0930aee 15.0 landed
-
Doc: prefer sysctl to /proc/sys in docs and comments.
- 4ee6740167b6 16.0 landed
- a0d87e2a92ea 10.23 landed
- d0371f190a1f 11.18 landed
- 384199ec5059 12.13 landed
- 384497f34de5 13.9 landed
- eb0097c6f3ee 14.6 landed
- d53ff6a44b32 15.0 landed
-
Remove our artificial PG_SOMAXCONN limit on listen queue length.
- 0f47457f1129 16.0 landed
-
Instead of believing SOMAXCONN from the system header files (which is
- 153f40067630 7.2.1 cited