pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
too many clients already
12+ messages / 4 participants
[nested] [flat]

* too many clients already
@ 2020-04-02 15:06  Abraham, Danny <danny_abraham@bmc.com>
  0 siblings, 3 replies; 12+ messages in thread

From: Abraham, Danny @ 2020-04-02 15:06 UTC (permalink / raw)
  To: pgsql-general; +Cc: Abraham, Danny <danny_abraham@bmc.com>

Hi,

Will appreciate a hint here.

Running on a big and stressed AIX platform and receiving lots of "CDTFATAL:  sorry, too many clients already"
and transient difficulty to log in.

Happens on all PG versions (Tested 9.5,10.4,11.5)

Big installation: max_connections is 1200,  shared_buffers is 2GB 

But .. select count(*) from pg_stat_activity   is only 66.

Thanks

Danny





^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: too many clients already
@ 2020-04-02 15:09  Rob Sargent <robjsargent@gmail.com>
  parent: Abraham, Danny <danny_abraham@bmc.com>
  2 siblings, 1 reply; 12+ messages in thread

From: Rob Sargent @ 2020-04-02 15:09 UTC (permalink / raw)
  To: Abraham, Danny <danny_abraham@bmc.com>; +Cc: pgsql-general



> On Apr 2, 2020, at 9:06 AM, Abraham, Danny <danny_abraham@bmc.com> wrote:
> 
> Hi,
> 
> Will appreciate a hint here.
> 
> Running on a big and stressed AIX platform and receiving lots of "CDTFATAL:  sorry, too many clients already"
> and transient difficulty to log in.
> 
> Happens on all PG versions (Tested 9.5,10.4,11.5)
> 
> Big installation: max_connections is 1200,  shared_buffers is 2GB 
> 
> But .. select count(*) from pg_stat_activity   is only 66.
> 
> Thanks
> 
> Danny
> 
> 
Lots of idle, kept-alive clients?  Do you have a connection pooler (e.g. pg-bouncer)?




^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: too many clients already
@ 2020-04-02 15:20  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Abraham, Danny <danny_abraham@bmc.com>
  2 siblings, 0 replies; 12+ messages in thread

From: Adrian Klaver @ 2020-04-02 15:20 UTC (permalink / raw)
  To: Abraham, Danny <danny_abraham@bmc.com>; pgsql-general

On 4/2/20 8:06 AM, Abraham, Danny wrote:
> Hi,
> 
> Will appreciate a hint here.
> 
> Running on a big and stressed AIX platform and receiving lots of "CDTFATAL:  sorry, too many clients already"
> and transient difficulty to log in.
> 
> Happens on all PG versions (Tested 9.5,10.4,11.5)
> 
> Big installation: max_connections is 1200,  shared_buffers is 2GB
> 
> But .. select count(*) from pg_stat_activity   is only 66.

On the chance pg_stat_activity is lying to you what does:

ps ax | grep post

show for backends?

For example:

ps ax | grep post
  1217 ?        Ss     0:00 /usr/lib/postfix/bin//master -w
  1233 ?        S      0:00 /usr/local/pgsql12/bin/postmaster -D 
/usr/local/pgsql12/data
  1253 ?        Ss     0:00 postgres: logger
  1277 ?        Ss     0:00 postgres: checkpointer
  1278 ?        Ss     0:00 postgres: background writer
  1279 ?        Ss     0:00 postgres: walwriter
  1280 ?        Ss     0:00 postgres: autovacuum launcher
  1281 ?        Ss     0:00 postgres: stats collector
  1282 ?        Ss     0:00 postgres: logical replication launcher 
*4693 ?        Ss     0:00 postgres: aklaver task_manager [local] idle
*4907 ?        Ss     0:00 postgres: aklaver production [local] idle

> 
> Thanks
> 
> Danny
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* RE:  Re: too many clients already
@ 2020-04-02 15:22  Abraham, Danny <danny_abraham@bmc.com>
  parent: Rob Sargent <robjsargent@gmail.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Abraham, Danny @ 2020-04-02 15:22 UTC (permalink / raw)
  To: pgsql-general; +Cc: Abraham, Danny <danny_abraham@bmc.com>

No pg-bouncer or connection pooling.
ps -elf | grep postgres | grep idle | wc -l  ==>    61

and BTW: Running, say 500 one command psql in parallel will have the same affect..

-----Original Message-----
From: Rob Sargent <robjsargent@gmail.com> 
Sent: Thursday, April 02, 2020 6:10 PM
To: Abraham, Danny <danny_abraham@bmc.com>
Cc: pgsql-general@postgresql.org
Subject: [EXTERNAL] Re: too many clients already



> On Apr 2, 2020, at 9:06 AM, Abraham, Danny <danny_abraham@bmc.com> wrote:
> 
> Hi,
> 
> Will appreciate a hint here.
> 
> Running on a big and stressed AIX platform and receiving lots of "CDTFATAL:  sorry, too many clients already"
> and transient difficulty to log in.
> 
> Happens on all PG versions (Tested 9.5,10.4,11.5)
> 
> Big installation: max_connections is 1200,  shared_buffers is 2GB 
> 
> But .. select count(*) from pg_stat_activity   is only 66.
> 
> Thanks
> 
> Danny
> 
> 
Lots of idle, kept-alive clients?  Do you have a connection pooler (e.g. pg-bouncer)?





^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: too many clients already
@ 2020-04-02 15:29  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Abraham, Danny <danny_abraham@bmc.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Adrian Klaver @ 2020-04-02 15:29 UTC (permalink / raw)
  To: Abraham, Danny <danny_abraham@bmc.com>; pgsql-general

On 4/2/20 8:22 AM, Abraham, Danny wrote:
> No pg-bouncer or connection pooling.
> ps -elf | grep postgres | grep idle | wc -l  ==>    61
> 
> and BTW: Running, say 500 one command psql in parallel will have the same affect..

Hmm. In psql on the cluster in question what does below return?:

show max_connections;

> 
> -----Original Message-----
> From: Rob Sargent <robjsargent@gmail.com>
> Sent: Thursday, April 02, 2020 6:10 PM
> To: Abraham, Danny <danny_abraham@bmc.com>
> Cc: pgsql-general@postgresql.org
> Subject: [EXTERNAL] Re: too many clients already
> 
> 
> 
>> On Apr 2, 2020, at 9:06 AM, Abraham, Danny <danny_abraham@bmc.com> wrote:
>>
>> Hi,
>>
>> Will appreciate a hint here.
>>
>> Running on a big and stressed AIX platform and receiving lots of "CDTFATAL:  sorry, too many clients already"
>> and transient difficulty to log in.
>>
>> Happens on all PG versions (Tested 9.5,10.4,11.5)
>>
>> Big installation: max_connections is 1200,  shared_buffers is 2GB
>>
>> But .. select count(*) from pg_stat_activity   is only 66.
>>
>> Thanks
>>
>> Danny
>>
>>
> Lots of idle, kept-alive clients?  Do you have a connection pooler (e.g. pg-bouncer)?
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* RE:  Re: too many clients already
@ 2020-04-02 15:35  Abraham, Danny <danny_abraham@bmc.com>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Abraham, Danny @ 2020-04-02 15:35 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general

Big installation: max_connections is 1200,  shared_buffers is 2GB

-----Original Message-----
From: Adrian Klaver <adrian.klaver@aklaver.com> 
Sent: Thursday, April 02, 2020 6:30 PM
To: Abraham, Danny <danny_abraham@bmc.com>; pgsql-general@postgresql.org
Subject: [EXTERNAL] Re: too many clients already

On 4/2/20 8:22 AM, Abraham, Danny wrote:
> No pg-bouncer or connection pooling.
> ps -elf | grep postgres | grep idle | wc -l  ==>    61
> 
> and BTW: Running, say 500 one command psql in parallel will have the same affect..

Hmm. In psql on the cluster in question what does below return?:

show max_connections;

> 
> -----Original Message-----
> From: Rob Sargent <robjsargent@gmail.com>
> Sent: Thursday, April 02, 2020 6:10 PM
> To: Abraham, Danny <danny_abraham@bmc.com>
> Cc: pgsql-general@postgresql.org
> Subject: [EXTERNAL] Re: too many clients already
> 
> 
> 
>> On Apr 2, 2020, at 9:06 AM, Abraham, Danny <danny_abraham@bmc.com> wrote:
>>
>> Hi,
>>
>> Will appreciate a hint here.
>>
>> Running on a big and stressed AIX platform and receiving lots of "CDTFATAL:  sorry, too many clients already"
>> and transient difficulty to log in.
>>
>> Happens on all PG versions (Tested 9.5,10.4,11.5)
>>
>> Big installation: max_connections is 1200,  shared_buffers is 2GB
>>
>> But .. select count(*) from pg_stat_activity   is only 66.
>>
>> Thanks
>>
>> Danny
>>
>>
> Lots of idle, kept-alive clients?  Do you have a connection pooler (e.g. pg-bouncer)?
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com


^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: too many clients already
@ 2020-04-02 15:37  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Abraham, Danny <danny_abraham@bmc.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Adrian Klaver @ 2020-04-02 15:37 UTC (permalink / raw)
  To: Abraham, Danny <danny_abraham@bmc.com>; pgsql-general

On 4/2/20 8:35 AM, Abraham, Danny wrote:
> Big installation: max_connections is 1200,  shared_buffers is 2GB

Have you confirmed that the above is actually in effect by doing?:

show max_connections;

> 
> -----Original Message-----
> From: Adrian Klaver <adrian.klaver@aklaver.com>
> Sent: Thursday, April 02, 2020 6:30 PM
> To: Abraham, Danny <danny_abraham@bmc.com>; pgsql-general@postgresql.org
> Subject: [EXTERNAL] Re: too many clients already
> 
> On 4/2/20 8:22 AM, Abraham, Danny wrote:
>> No pg-bouncer or connection pooling.
>> ps -elf | grep postgres | grep idle | wc -l  ==>    61
>>
>> and BTW: Running, say 500 one command psql in parallel will have the same affect..
> 
> Hmm. In psql on the cluster in question what does below return?:
> 
> show max_connections;
> 
>>
>> -----Original Message-----
>> From: Rob Sargent <robjsargent@gmail.com>
>> Sent: Thursday, April 02, 2020 6:10 PM
>> To: Abraham, Danny <danny_abraham@bmc.com>
>> Cc: pgsql-general@postgresql.org
>> Subject: [EXTERNAL] Re: too many clients already
>>
>>
>>
>>> On Apr 2, 2020, at 9:06 AM, Abraham, Danny <danny_abraham@bmc.com> wrote:
>>>
>>> Hi,
>>>
>>> Will appreciate a hint here.
>>>
>>> Running on a big and stressed AIX platform and receiving lots of "CDTFATAL:  sorry, too many clients already"
>>> and transient difficulty to log in.
>>>
>>> Happens on all PG versions (Tested 9.5,10.4,11.5)
>>>
>>> Big installation: max_connections is 1200,  shared_buffers is 2GB
>>>
>>> But .. select count(*) from pg_stat_activity   is only 66.
>>>
>>> Thanks
>>>
>>> Danny
>>>
>>>
>> Lots of idle, kept-alive clients?  Do you have a connection pooler (e.g. pg-bouncer)?
>>
>>
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* RE:  Re: too many clients already
@ 2020-04-02 15:41  Abraham, Danny <danny_abraham@bmc.com>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 0 replies; 12+ messages in thread

From: Abraham, Danny @ 2020-04-02 15:41 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general

va-tlv-ctm-qa22.isr.bmc.com% sql
psql: FATAL:  sorry, too many clients already
va-tlv-ctm-qa22.isr.bmc.com% sql
psql (11.5)
Type "help" for help.

ctrlmdb=> show max_connections;
 max_connections
-----------------
 1200
(1 row)

ctrlmdb=> show shared_buffers;
 shared_buffers
----------------
 2000MB
(1 row)



-----Original Message-----
From: Adrian Klaver <adrian.klaver@aklaver.com> 
Sent: Thursday, April 02, 2020 6:37 PM
To: Abraham, Danny <danny_abraham@bmc.com>; pgsql-general@postgresql.org
Subject: [EXTERNAL] Re: too many clients already

On 4/2/20 8:35 AM, Abraham, Danny wrote:
> Big installation: max_connections is 1200,  shared_buffers is 2GB

Have you confirmed that the above is actually in effect by doing?:

show max_connections;

> 
> -----Original Message-----
> From: Adrian Klaver <adrian.klaver@aklaver.com>
> Sent: Thursday, April 02, 2020 6:30 PM
> To: Abraham, Danny <danny_abraham@bmc.com>; pgsql-general@postgresql.org
> Subject: [EXTERNAL] Re: too many clients already
> 
> On 4/2/20 8:22 AM, Abraham, Danny wrote:
>> No pg-bouncer or connection pooling.
>> ps -elf | grep postgres | grep idle | wc -l  ==>    61
>>
>> and BTW: Running, say 500 one command psql in parallel will have the same affect..
> 
> Hmm. In psql on the cluster in question what does below return?:
> 
> show max_connections;
> 
>>
>> -----Original Message-----
>> From: Rob Sargent <robjsargent@gmail.com>
>> Sent: Thursday, April 02, 2020 6:10 PM
>> To: Abraham, Danny <danny_abraham@bmc.com>
>> Cc: pgsql-general@postgresql.org
>> Subject: [EXTERNAL] Re: too many clients already
>>
>>
>>
>>> On Apr 2, 2020, at 9:06 AM, Abraham, Danny <danny_abraham@bmc.com> wrote:
>>>
>>> Hi,
>>>
>>> Will appreciate a hint here.
>>>
>>> Running on a big and stressed AIX platform and receiving lots of "CDTFATAL:  sorry, too many clients already"
>>> and transient difficulty to log in.
>>>
>>> Happens on all PG versions (Tested 9.5,10.4,11.5)
>>>
>>> Big installation: max_connections is 1200,  shared_buffers is 2GB
>>>
>>> But .. select count(*) from pg_stat_activity   is only 66.
>>>
>>> Thanks
>>>
>>> Danny
>>>
>>>
>> Lots of idle, kept-alive clients?  Do you have a connection pooler (e.g. pg-bouncer)?
>>
>>
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com


^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: too many clients already
@ 2020-04-02 15:51  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Abraham, Danny <danny_abraham@bmc.com>
  2 siblings, 1 reply; 12+ messages in thread

From: Tom Lane @ 2020-04-02 15:51 UTC (permalink / raw)
  To: Abraham, Danny <danny_abraham@bmc.com>; +Cc: pgsql-general

"Abraham, Danny" <danny_abraham@bmc.com> writes:
> Running on a big and stressed AIX platform and receiving lots of "CDTFATAL:  sorry, too many clients already"
> and transient difficulty to log in.
> Happens on all PG versions (Tested 9.5,10.4,11.5)
> Big installation: max_connections is 1200,  shared_buffers is 2GB 
> But .. select count(*) from pg_stat_activity   is only 66.

I'd be suspicious that there are a lot of clients stuck in connection
startup (likely the authentication phase); those connections aren't going
to show in pg_stat_activity until they finish connecting.  The "ps"
suggestion Adrian gave you would not show them either, because they're
not going to say "idle".

Enabling log_connections and watching the postmaster log would help
prove or disprove that theory.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* RE:  Re: too many clients already
@ 2020-04-02 16:20  Abraham, Danny <danny_abraham@bmc.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 12+ messages in thread

From: Abraham, Danny @ 2020-04-02 16:20 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general

Well, I guess the questions is - how do I optimize PG for a stream of very short life checks...
See below:

2020-04-02 11:05:37.010 CDTLOG:  connection received: host=10.64.72.157 port=45799
2020-04-02 11:05:37.014 CDTLOG:  connection received: host=10.64.72.157 port=45814
2020-04-02 11:05:37.014 CDTLOG:  connection received: host=10.64.72.157 port=45813
2020-04-02 11:05:37.018 CDTFATAL:  sorry, too many clients already
2020-04-02 11:05:37.015 CDTLOG:  connection received: host=10.64.72.157 port=45815
2020-04-02 11:05:37.015 CDTLOG:  connection received: host=10.64.72.157 port=45817
2020-04-02 11:05:37.015 CDTLOG:  connection received: host=10.64.72.157 port=45809
2020-04-02 11:05:37.015 CDTLOG:  connection received: host=10.64.72.157 port=45818
2020-04-02 11:05:37.016 CDTLOG:  connection received: host=10.64.72.157 port=45819
2020-04-02 11:05:37.021 CDTFATAL:  sorry, too many clients already
2020-04-02 11:05:37.021 CDTFATAL:  sorry, too many clients already
2020-04-02 11:05:37.021 CDTFATAL:  sorry, too many clients already
2020-04-02 11:05:37.021 CDTFATAL:  sorry, too many clients already
2020-04-02 11:05:37.021 CDTFATAL:  sorry, too many clients already
2020-04-02 11:05:37.022 CDTFATAL:  sorry, too many clients already
2020-04-02 11:05:37.022 CDTFATAL:  sorry, too many clients already
-----Original Message-----
From: Tom Lane <tgl@sss.pgh.pa.us> 
Sent: Thursday, April 02, 2020 6:52 PM
To: Abraham, Danny <danny_abraham@bmc.com>
Cc: pgsql-general@postgresql.org
Subject: [EXTERNAL] Re: too many clients already

"Abraham, Danny" <danny_abraham@bmc.com> writes:
> Running on a big and stressed AIX platform and receiving lots of "CDTFATAL:  sorry, too many clients already"
> and transient difficulty to log in.
> Happens on all PG versions (Tested 9.5,10.4,11.5) Big installation: 
> max_connections is 1200,  shared_buffers is 2GB
> But .. select count(*) from pg_stat_activity   is only 66.

I'd be suspicious that there are a lot of clients stuck in connection startup (likely the authentication phase); those connections aren't going to show in pg_stat_activity until they finish connecting.  The "ps"
suggestion Adrian gave you would not show them either, because they're not going to say "idle".

Enabling log_connections and watching the postmaster log would help prove or disprove that theory.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: too many clients already
@ 2020-04-02 16:40  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Abraham, Danny <danny_abraham@bmc.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Tom Lane @ 2020-04-02 16:40 UTC (permalink / raw)
  To: Abraham, Danny <danny_abraham@bmc.com>; +Cc: pgsql-general

"Abraham, Danny" <danny_abraham@bmc.com> writes:
> Well, I guess the questions is - how do I optimize PG for a stream of very short life checks...

You should be using a connection pooler for a load like that.
PG backends are fairly heavyweight things --- you don't want
to fire one up for just a single query, at least not when
there are many such queries per second.

I think pgbouncer and pgpool are the most widely used options,
but this is a bit outside my expertise.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* RE:  Re: too many clients already
@ 2020-04-02 17:13  Abraham, Danny <danny_abraham@bmc.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 12+ messages in thread

From: Abraham, Danny @ 2020-04-02 17:13 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general

Agree.

I suspect that this is a mal configured pgpool - the developer thinks that the pool is reusing connections,
While it is, in fact, reopening them.

-----Original Message-----
From: Tom Lane <tgl@sss.pgh.pa.us> 
Sent: Thursday, April 02, 2020 7:40 PM
To: Abraham, Danny <danny_abraham@bmc.com>
Cc: pgsql-general@postgresql.org
Subject: [EXTERNAL] Re: too many clients already

"Abraham, Danny" <danny_abraham@bmc.com> writes:
> Well, I guess the questions is - how do I optimize PG for a stream of very short life checks...

You should be using a connection pooler for a load like that.
PG backends are fairly heavyweight things --- you don't want to fire one up for just a single query, at least not when there are many such queries per second.

I think pgbouncer and pgpool are the most widely used options, but this is a bit outside my expertise.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 12+ messages in thread


end of thread, other threads:[~2020-04-02 17:13 UTC | newest]

Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-04-02 15:06 too many clients already Abraham, Danny <danny_abraham@bmc.com>
2020-04-02 15:09 ` Rob Sargent <robjsargent@gmail.com>
2020-04-02 15:22   ` Abraham, Danny <danny_abraham@bmc.com>
2020-04-02 15:29     ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-04-02 15:35       ` Abraham, Danny <danny_abraham@bmc.com>
2020-04-02 15:37         ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-04-02 15:41           ` Abraham, Danny <danny_abraham@bmc.com>
2020-04-02 15:20 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-04-02 15:51 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-04-02 16:20   ` Abraham, Danny <danny_abraham@bmc.com>
2020-04-02 16:40     ` Tom Lane <tgl@sss.pgh.pa.us>
2020-04-02 17:13       ` Abraham, Danny <danny_abraham@bmc.com>

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