Обсуждение: PHPs PDO, apache and "never ending sessions"
Hi, Not sure whether this is the right place to ask (probably isn't) but I've seen much mention of PHP and some of PDO on this list ... I'm currently playing with the above, today I got a message "FATAL: connection limit exceeded for non-superusers" even though there were no sessions I was aware of open. A bit of poking around with ps and lsof showed me that a PHP application I closed days ago (no browser open) was still active tying up backend sessions; the problem went away when I restarted my apache. Is this "normal behaviour"? How do I deal with it under normal circumstance, am I just supposed to increase the number of allowed connections and not worry about apache holding sessions open even after the "client" has long gone? Versions of products in question: apache2 2.2.8 (Unix) PHP 5.2.5 postgres 8.3 Cheers, Andrej -- Please don't top post, and don't use HTML e-Mail :} Make your quotes concise. http://www.american.edu/econ/notes/htmlmail.htm
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Fri, 7 Mar 2008 15:01:11 +1300 "Andrej Ricnik-Bay" <andrej.groups@gmail.com> wrote: > Hi, > > Not sure whether this is the right place to ask (probably isn't) > but I've seen much mention of PHP and some of PDO on this > list ... > > I'm currently playing with the above, today I got a message > "FATAL: connection limit exceeded for non-superusers" > even though there were no sessions I was aware of open. > > A bit of poking around with ps and lsof showed me that a PHP > application I closed days ago (no browser open) was still active > tying up backend sessions; the problem went away when I > restarted my apache. Is this "normal behaviour"? How do I > deal with it under normal circumstance, am I just supposed > to increase the number of allowed connections and not worry > about apache holding sessions open even after the "client" > has long gone? It depends on how you are connecting. For example if you are doing this: PDO::ATTR_PERSISTENT => true Then... yeah :). You really shouldn't use a language layer for persistent connections though. Use pgbouncer or pgpool. Joshua D. Drake > > Versions of products in question: > apache2 2.2.8 (Unix) > PHP 5.2.5 > postgres 8.3 > > > Cheers, > Andrej > - -- The PostgreSQL Company since 1997: http://www.commandprompt.com/ PostgreSQL Community Conference: http://www.postgresqlconference.org/ Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate PostgreSQL SPI Liaison | SPI Director | PostgreSQL political pundit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFH0KXoATb/zqfZUUQRAizLAKCivP6r2g2QX2jVcG9xqeTJl+tbVwCfdv3c jdkOZjn1S129nHYLKBamAKg= =adRV -----END PGP SIGNATURE-----
On 07/03/2008, Joshua D. Drake <jd@commandprompt.com> wrote: > > A bit of poking around with ps and lsof showed me that a PHP > > application I closed days ago (no browser open) was still active > > tying up backend sessions; the problem went away when I > > restarted my apache. Is this "normal behaviour"? How do I > > deal with it under normal circumstance, am I just supposed > > to increase the number of allowed connections and not worry > > about apache holding sessions open even after the "client" > > has long gone? > It depends on how you are connecting. For example if you are doing this: > > PDO::ATTR_PERSISTENT => true > > Then... yeah :). You really shouldn't use a language layer for > persistent connections though. Use pgbouncer or pgpool. Thanks Joshua. It was indeed set to true; I was playing with the "hatshop" database and application from the "Beginning PHP and PostgreSQL E-Commerce" Apress book. And found that config.php has "define('DB_PERSISTENCY', 'true');". Thanks for pointing me in the right direction. > Joshua D. Drake Cheers, Andrej -- Please don't top post, and don't use HTML e-Mail :} Make your quotes concise. http://www.american.edu/econ/notes/htmlmail.htm
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sat, 8 Mar 2008 09:06:22 +1300 "Andrej Ricnik-Bay" <andrej.groups@gmail.com> wrote: > > PDO::ATTR_PERSISTENT => true > > > > Then... yeah :). You really shouldn't use a language layer for > > persistent connections though. Use pgbouncer or pgpool. > Thanks Joshua. It was indeed set to true; I was playing with > the "hatshop" database and application from the "Beginning > PHP and PostgreSQL E-Commerce" Apress book. And found > that config.php has "define('DB_PERSISTENCY', 'true');". Thanks > for pointing me in the right direction. That is what we are here for :). Glad we could help. Joshua D. Drake - -- The PostgreSQL Company since 1997: http://www.commandprompt.com/ PostgreSQL Community Conference: http://www.postgresqlconference.org/ Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate PostgreSQL SPI Liaison | SPI Director | PostgreSQL political pundit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFH0aERATb/zqfZUUQRAnH+AJwPiWWeQrxP1O7YfE5E9lhKtyyanwCaAzTq 6Udd4wB5NIODtOqjlGnfGus= =FllY -----END PGP SIGNATURE-----