Too many clients

Too many clients

am 27.02.2004 22:11:33 von Andy Dunlop

I hope this goes to the right place!

I occasionally get the error "too many clients" when connecting to the
database. I try restarting the Postgres server and also Apache, but the
only thing that clears the problem is restarting Linux. I have maxusers
set to 35, and I am the only user, so I suspect I am not doing something
in my scripts that I should be, or doing something that I shouldn't be!
I have the pg_connect at the top of the script so each time it loads the
page it does a new connect - maybe this is a problem?

Probably a simple solution, anyone know?
Thanks
Andy


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Re: Too many clients

am 27.02.2004 22:16:36 von Devrim GUNDUZ

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi,

On 27 Feb 2004, Andy Dunlop wrote:

> I occasionally get the error "too many clients" when connecting to the
> database. I try restarting the Postgres server and also Apache, but the
> only thing that clears the problem is restarting Linux. I have maxusers
> set to 35, and I am the only user, so I suspect I am not doing something
> in my scripts that I should be, or doing something that I shouldn't be!
> I have the pg_connect at the top of the script so each time it loads the
> page it does a new connect - maybe this is a problem?

The max_connections parameter of PostgreSQL is the max number of
connections 'at the same time'.

So, if your web site has more than 33 visitors (let's say 2 connections
were "superuser_reserved_connections") at the same time, then you'll get
the error "too many connections". BTW, PHP calls pg_close() at the end of
script execution, if you are using pg_connect ('not pg_pconnect') at the
beginning of the script.

To get rid of that error,
* Make sure that you aren't using pg_pconnect
* Increase max_connections parameter, as well as the parameters related to
it.

Regards,
- --
Devrim GUNDUZ
devrim@gunduz.org devrim.gunduz@linux.org.tr
http://www.TDMSoft.com
http://www.gunduz.org

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFAP7O2tl86P3SPfQ4RAvnbAKCTRWe1MT/L3ps6TVCIvTduyGozTACf fmde
Yp3RnOxG90Q7LawzzhTLyC8=
=+cPt
-----END PGP SIGNATURE-----


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Re: Too many clients

am 27.02.2004 22:46:57 von Scott Marlowe

On 27 Feb 2004, Andy Dunlop wrote:

> I hope this goes to the right place!
>
> I occasionally get the error "too many clients" when connecting to the
> database. I try restarting the Postgres server and also Apache, but the
> only thing that clears the problem is restarting Linux. I have maxusers
> set to 35, and I am the only user, so I suspect I am not doing something
> in my scripts that I should be, or doing something that I shouldn't be!
> I have the pg_connect at the top of the script so each time it loads the
> page it does a new connect - maybe this is a problem?

1: Make sure you're not using pg_pconnect, but this doesn't sound like
that's the problem. Just making sure.

2: It sounds like php may be crashing at some point it its execution. Do
you have a log of its output when it's running? I've seen issues where if
you compile apache against one set of libs and php against another, then
apache/php starts having children crash and doesn't close the connections.
It takes a certain amount of time for the timeout to hit on the TCP/IP
layer and for the pg backend to close.

Are you sure you're actually closing down postgresql all the way when you
say you tried restarting the postgresql server? It could be that it's not
shutting all the way down. What does 'ps ax|grep post' say?


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html