durusmail: quixote-users: [slightly OT] persistent postgresql connection problem
[slightly OT] persistent postgresql connection problem
2004-10-12
2004-10-12
[slightly OT] persistent postgresql connection problem
Dave Kuhlman
2004-10-12
On Tue, Oct 12, 2004 at 08:03:24PM +0200, Ksenia Marasanova wrote:
> I have a custom publisher class for persistent database connection,
> based on this wiki page: http://www.quixote.ca/qx/ReusingConnections. I
> use it with PostgreSQL, psycopg and SCGI server. But there must be
> something wrong with my code, because after a while the process list is
> full of postgres connections, some of them "idle", some "idle in
> transaction". The application keeps running fine (I think), but every
> attempt to make a new connection (for example, from a cron script)
> falls with an error: "FATAL, Sorry, too many clients already". Looks
> like maximum number of connections is reached... unused connections not
> being closed?
>
> I realize that it is not a Quixote problem, but was hoping someone with
> the same configuration can give an advise -- like, where (and how) to
> debug?!

If it's "full of postgres connections", then the following does not
explain your problem, but ... When debugging this, keep in mind
that the method described in that Wiki page creates and holds one
connection for each process.  With SCGI, by default, Quixote
creates up to 5 processes, I believe, when it needs to in order to
handle multiple concurrent requests.  It's supposed to work that
way.  It prevents request handlers from using the same connection
at the same time.

So, even when you solve the problem that you describe, you may find
more than one connection in the process list.

Dave


reply