Обсуждение: [GENERAL] sorry, too many clients already error

Поиск
Список
Период
Сортировка

[GENERAL] sorry, too many clients already error

От
Sandeep Gupta
Дата:
I have set max_connection = 40.

The usage is somewhat not typical. It is basically
experiment runs that connect to the database
and dump results there.

The experiments connect through JDBC and
they close the connection when they are done.

I can verify that no more than 20 clients/experiments
are active at any given time.

What could be the cause of the database issuing
too many clients error. Could I have set resources too high?

Thanks.
-sandeep


Re: [GENERAL] sorry, too many clients already error

От
Tom Lane
Дата:
Sandeep Gupta <gupta.sandeep@gmail.com> writes:
> I have set max_connection = 40.
> The usage is somewhat not typical. It is basically
> experiment runs that connect to the database
> and dump results there.

> The experiments connect through JDBC and
> they close the connection when they are done.

> I can verify that no more than 20 clients/experiments
> are active at any given time.

It takes nonzero time for a backend process to actually exit after
the client has closed the connection.  (A client that wants to wait
for backend exit can do so by waiting for EOF on the socket, but
I doubt that the JDBC driver does so.)  If you're spinning through
sessions rapidly enough, you might just have >20 sessions that are
still in process of exiting when a new one comes in and gets this
error.

It'd also be a good thing to see if the client code is sending an
actual Terminate protocol message ('X') or is just closing the
socket.  If the latter, maybe it isn't really closing because the
socket is shared with some child process, or something like that?

Turning on log_connections/log_disconnections might help clarify
what's happening.

            regards, tom lane


Re: [GENERAL] sorry, too many clients already error

От
Sandeep Gupta
Дата:
The log_connections helped. I was able
to diagnose the problem. The connections
are getting closed but my setup is actually generating
too many connections.
Thanks for helping with this.

-sandeep


On Tue, May 16, 2017 at 6:53 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Sandeep Gupta <gupta.sandeep@gmail.com> writes:
>> I have set max_connection = 40.
>> The usage is somewhat not typical. It is basically
>> experiment runs that connect to the database
>> and dump results there.
>
>> The experiments connect through JDBC and
>> they close the connection when they are done.
>
>> I can verify that no more than 20 clients/experiments
>> are active at any given time.
>
> It takes nonzero time for a backend process to actually exit after
> the client has closed the connection.  (A client that wants to wait
> for backend exit can do so by waiting for EOF on the socket, but
> I doubt that the JDBC driver does so.)  If you're spinning through
> sessions rapidly enough, you might just have >20 sessions that are
> still in process of exiting when a new one comes in and gets this
> error.
>
> It'd also be a good thing to see if the client code is sending an
> actual Terminate protocol message ('X') or is just closing the
> socket.  If the latter, maybe it isn't really closing because the
> socket is shared with some child process, or something like that?
>
> Turning on log_connections/log_disconnections might help clarify
> what's happening.
>
>                         regards, tom lane