Re: pgbench: could not connect to server: Resource temporarily unavailable

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Kevin McKibbin <kevinmckibbin123(at)gmail(dot)com>, pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: pgbench: could not connect to server: Resource temporarily unavailable
Date: 2022-08-21 22:55:31
Message-ID: 68893.1661122531@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Thomas Munro <thomas(dot)munro(at)gmail(dot)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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Thomas Munro 2022-08-21 23:33:33 Re: pgbench: could not connect to server: Resource temporarily unavailable
Previous Message Andres Freund 2022-08-21 22:43:31 Re: pgbench: could not connect to server: Resource temporarily unavailable