From: Tom Lane <tgl@sss.pgh.pa.us>
To: bhargav kamineni <bhargavpostgres@gmail.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: PMChildFlags array
Date: Thu, 03 Oct 2019 18:19:06 -0400
Message-ID: <28891.1570141146@sss.pgh.pa.us> (raw)
In-Reply-To: <CADCf-WNiKA+EWwLkJLwK1FKEU2_kMDDNgH-d-fbBXW-PQ3Xi0A@mail.gmail.com>
References: <CADCf-WNZk_9680Q0YjfBzuiR0Oe8LzvDs2Ts3_tq6Tv1e8raQQ@mail.gmail.com>
<3909bd80-97e0-9365-fe98-86b62683a400@aklaver.com>
<CADCf-WNiKA+EWwLkJLwK1FKEU2_kMDDNgH-d-fbBXW-PQ3Xi0A@mail.gmail.com>
bhargav kamineni <bhargavpostgres@gmail.com> writes:
>> What was the database doing just before the FATAL line?
> Postgres was rejecting a bunch of connections from a user who is having a
> connection limit set. that was the the FATAL error that i could see in log
> file.
> FATAL,53300,"too many connections for role ""user_app"""
So ... how many is "a bunch"?
Looking at the code, it seems like it'd be possible for a sufficiently
aggressive spawner of incoming connections to reach the
MaxLivePostmasterChildren limit. While the postmaster would correctly
reject additional connection attempts after that, what it would not do
is ensure that any child slots are left for new parallel worker processes.
So we could hypothesize that the error you're seeing in the log is from
failure to spawn a parallel worker process, due to being out of child
slots.
However, given that max_connections = 500, MaxLivePostmasterChildren()
would be 1000-plus. This would mean that reaching this condition would
require *at least* 500 concurrent connection-attempts-that-haven't-yet-
been-rejected, maybe well more than that if you didn't have close to
500 legitimately open sessions. That seems like a lot, enough to suggest
that you've got some pretty serious bug in your client-side logic.
Anyway, I think it's clearly a bug that canAcceptConnections() thinks the
number of acceptable connections is identical to the number of allowed
child processes; it needs to be less, by the number of background
processes we want to support. But it seems like a darn hard-to-hit bug,
so I'm not quite sure that that explains your observation.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, bhargavpostgres@gmail.com, adrian.klaver@aklaver.com
Subject: Re: PMChildFlags array
In-Reply-To: <28891.1570141146@sss.pgh.pa.us>
References: <CADCf-WNZk_9680Q0YjfBzuiR0Oe8LzvDs2Ts3_tq6Tv1e8raQQ@mail.gmail.com> <3909bd80-97e0-9365-fe98-86b62683a400@aklaver.com> <CADCf-WNiKA+EWwLkJLwK1FKEU2_kMDDNgH-d-fbBXW-PQ3Xi0A@mail.gmail.com> <28891.1570141146@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