Re: Installed. Now what? - Mailing list pgsql-general

From Tomas Vondra
Subject Re: Installed. Now what?
Date
Msg-id 4EC9AFE6.4090003@fuzzy.cz
Whole thread Raw
In response to Re: Installed. Now what?  (Phoenix Kiula <phoenix.kiula@gmail.com>)
List pgsql-general
Dne 20.11.2011 12:52, Phoenix Kiula napsal(a):
> You may be on to something. And the queries results are below. (5
> connections are reserved for "superusers" so you may be right.)
>
>
> MYDB=# show max_connections;
>  max_connections
> -----------------
>  150
> (1 row)
>
> Time: 0.517 ms
>
>
> MYDB=#   select count(1) from pg_stat_activity;
>  count
> -------
>    144
> (1 row)
>
> Time: 1.541 ms

The limit actually is not max_connections, as certain number of
connections is reserved for superusers (maintenance etc.). It's
specified by superuser_reserved_connections - by default it's set to 3,
so there are only 147 connections available.

> But isn't the point to connect to pgbouncer (instead of PG directly)
> and have it manage connections? Even when I restart PG so that its
> connection count is fresh and low, and immediately try to connect to
> pgbouncer, it still shows me an error.

Sure, but pgbouncer has to actually open a regular connection to the
database - those are regular connections, and the connection fails
because of reaching max_connections, pgbouncer can't do anything with it.

The point of connection pooler is that there'll be limited number of
pre-created connections, handed to clients. I see you have set

max_client_conn = 100
default_pool_size = 20

which means there will be at most 20 database connections, and 100
clients can connect to the pooler. Once all those 20 connections are
used, the other clients have to wait.

BTW "max_client_conn = 100" means that at most 100 clients can connect
to the pooler, if there are more clients the connection will fail with
the same error as when reaching max_connections. As you were getting
"too many clients" with max_connections=350, you should probably
significantly increase max_client_conn - e.g. to 400.

> How can I debug that the connections are the problem?

Check the postgresql log file?

> The error message in the pgbouncer log points to some "FATAL password
> authentication".

Then it probably is not caused by reaching max_connections. But I'm not
sure about this - maybe pgbouncer returns this when the database reaches
max_connections.

Tomas

pgsql-general by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: Huge number of INSERTs
Next
From: Tomas Vondra
Date:
Subject: Re: Installed. Now what?