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: Thomas Munro <thomas.munro@gmail.com>
Cc: Andrew Dunstan <andrew@dunslane.net>,
Kevin McKibbin <kevinmckibbin123@gmail.com>,
pgsql-performance@lists.postgresql.org
Date: 2022-08-21T22:55:31Z
Lists: pgsql-performance
Thomas Munro <thomas.munro@gmail.com> writes: > If it's something like that, maybe increasing > /proc/sys/net/core/somaxconn would help? I think older kernels only > had 128 here. Bingo! I see $ cat /proc/sys/net/core/somaxconn 128 by default, which is right about where the problem starts. After $ sudo sh -c 'echo 1000 >/proc/sys/net/core/somaxconn' *and restarting the PG server*, I can do a lot more threads without a problem. Evidently, the server's socket's listen queue length is fixed at creation and adjusting the kernel limit won't immediately change it. So what we've got is that EAGAIN from connect() on a Unix socket can mean "listen queue overflow" and the kernel won't treat that as a nonblock-waitable condition. Still seems like a kernel bug perhaps, or at least a misfeature. Not sure what I think at this point about making libpq retry after EAGAIN. It would make sense for this particular undocumented use of EAGAIN, but I'm worried about others, especially the documented reason. On the whole I'm inclined to leave the code alone; but is there sufficient reason to add something about adjusting somaxconn to our documentation? 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