Thread: Too many open connections
I keep getting the following error message: Warning: PostgreSQL: Too many open links (2) I've searched in the DOCs and FAQs, but no luck. How do I increase the maximum number of connections? I've started postmaster with "-N 64 -B 128". Or could it be something else that's causing this? Just starting out with pgsql, and nobody @office knows anything about it. Grtz, P. Mylonopoulos Trilab BV / V3 Javastraat 2c 2585AM Den Haag Tel: +31-70-3457123 ------------------------------------------------------------ Who is General Failure? And why is he reading my disk? ------------------------------------------------------------
Petros Mylonopoulos <petros@gate.v3.com> writes: > I keep getting the following error message: > Warning: PostgreSQL: Too many open links (2) > I've searched in the DOCs and FAQs, but no luck. How do I increase the > maximum number of connections? I've started postmaster with "-N 64 -B > 128". That's not a too-many-open-connections error. I don't know what it is, in fact --- but I can tell you there is no such error message string anywhere in the 7.0.* source code, because I just looked. It must be coming out of some non-PG code, perhaps a startup script or the C library. What PG version are you using, on what platform? Exactly when and where does this message show up? regards, tom lane
> What PG version are you using, on what platform? Exactly when and where > does this message show up? We're running the last i386 debian linux, kernel v2.4.0, pgsql 7.0.2. The errormessage pop up whenever the database is connected for image withdrawal. It's all over the website. When the database was running on slowaris7 we did not get these errors. Just increidibly high load, which I "fixed" by using kernel parameters for Oracle 8.0.5 We've got a website which retrieves it's images and user info from a pgsql database. The full error message is Warning: PostgreSQL: Too many open links (2) in /opt/apache/www/jippy/db.inc.php on line 63 Line 63 of db.inc.php is the last of the 3 following: function Open ($host, $user, $pass, $db) { $port = "5432"; $this->_db_linkid = pg_Connect ("host=$host port=$port dbname=$db user=$user password=$pass"); Pgsql and apache are not running on the same machine, in case you were wondering. > regards, tom lane Thnx for the speedy reply. Hope I gve enough info. Grtz, P. Mylonopoulos Trilab BV / V3 Javastraat 2c 2585AM Den Haag Tel: +31-70-3457123 ------------------------------------------------------------ Who is General Failure? And why is he reading my disk? ------------------------------------------------------------
Petros Mylonopoulos <petros@gate.v3.com> writes: > We've got a website which retrieves it's images and user info from a pgsql > database. The full error message is > Warning: PostgreSQL: Too many open links (2) in > /opt/apache/www/jippy/db.inc.php on line 63 > Line 63 of db.inc.php is the last of the 3 following: > function Open ($host, $user, $pass, $db) { > $port = "5432"; > $this->_db_linkid = pg_Connect ("host=$host port=$port dbname=$db user=$user password=$pass"); OK, it would seem that you are running into some limitation in PHP's support for multiple connections to a database. I don't know anything about PHP, so I can't help you myself. If you search for stuff about PHP in the pgsql-interfaces mail list archives, you might find the answer. If no luck that way, I suggest asking about it on that list... regards, tom lane
This looks very much like the PHP limit of open connections per process. You can look in the php.ini file for "pgsql.max_links" and you should see what it is configured for. Also without seeing the entire code (i'll make a few assumptions) it appears that the code is within a ?class? and I didn't see any checks to see if there was already a connection to the database. You may want to check to see if a connection has already been made within that class and close it before opening a new one. This however may not be the cause if you are creating a new class each time thereby creating a new connection. Without knowing more about what it is you are trying to do and how you are doing it hard to really say if it is the best way or a better way to do it. Hope this helps a little. Chris Ryan chris@greatbridge.com Petros Mylonopoulos wrote: > > > What PG version are you using, on what platform? Exactly when and where > > does this message show up? > > We're running the last i386 debian linux, kernel v2.4.0, pgsql 7.0.2. > The errormessage pop up whenever the database is connected for image > withdrawal. It's all over the website. When the database was running on > slowaris7 we did not get these errors. Just increidibly high load, which I > "fixed" by using kernel parameters for Oracle 8.0.5 > > We've got a website which retrieves it's images and user info from a pgsql > database. The full error message is > > Warning: PostgreSQL: Too many open links (2) in > /opt/apache/www/jippy/db.inc.php on line 63 > > Line 63 of db.inc.php is the last of the 3 following: > > function Open ($host, $user, $pass, $db) { > $port = "5432"; > $this->_db_linkid = pg_Connect ("host=$host port=$port dbname=$db user=$user password=$pass"); > > Pgsql and apache are not running on the same machine, in case you were > wondering. > > > regards, tom lane > Thnx for the speedy reply. Hope I gve enough info. > > Grtz, > P. Mylonopoulos > Trilab BV / V3 > Javastraat 2c > 2585AM Den Haag > Tel: +31-70-3457123 > > ------------------------------------------------------------ > Who is General Failure? > And why is he reading my disk? > ------------------------------------------------------------
> OK, it would seem that you are running into some limitation in PHP's > support for multiple connections to a database. I don't know anything > about PHP, so I can't help you myself. If you search for stuff about > PHP in the pgsql-interfaces mail list archives, you might find the > answer. If no luck that way, I suggest asking about it on that list... Thnx for the effort anyhoo. Grtz, P. Mylonopoulos Trilab BV / V3 Javastraat 2c 2585AM Den Haag Tel: +31-70-3457123 ------------------------------------------------------------ Who is General Failure? And why is he reading my disk? ------------------------------------------------------------
> This looks very much like the PHP limit of open connections per > process. You can look in the php.ini file for "pgsql.max_links" and you > should see what it is configured for. You were right on the money. Thnx a zillion. Whenever we meet, I owe you a cookie. Grtz, P. Mylonopoulos Trilab BV / V3 Javastraat 2c 2585AM Den Haag Tel: +31-70-3457123 ------------------------------------------------------------ Who is General Failure? And why is he reading my disk? ------------------------------------------------------------