From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: Kevin McKibbin <kevinmckibbin123@gmail.com>
Cc: pgsql-performance@lists.postgresql.org
Subject: Re: pgbench: could not connect to server: Resource temporarily unavailable
Date: Sun, 21 Aug 2022 18:55:31 -0400
Message-ID: <68893.1661122531@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+hUKGLTNSJrKYByirsSyqodmp28McpNUCL5-gvCLXtOj0RwBQ@mail.gmail.com>
References: <CADc_NKg2d+oZY9mg4DdQdoUcGzN2kOYXBu-3--RW_hEe0tUV=g@mail.gmail.com>
<3909995.1661052002@sss.pgh.pa.us>
<35d221aa-3da4-f744-3965-ceca7f71f4ea@dunslane.net>
<8864.1661116501@sss.pgh.pa.us>
<83134bb1-3a21-059f-1cd6-4997de2652b8@dunslane.net>
<33898.1661118503@sss.pgh.pa.us>
<CA+hUKGLTNSJrKYByirsSyqodmp28McpNUCL5-gvCLXtOj0RwBQ@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, thomas.munro@gmail.com, andrew@dunslane.net, kevinmckibbin123@gmail.com, pgsql-performance@lists.postgresql.org
Subject: Re: pgbench: could not connect to server: Resource temporarily unavailable
In-Reply-To: <68893.1661122531@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox