Re: libpq enhancement for multi-process application - Mailing list pgsql-hackers

From Sébastien Bonnet
Subject Re: libpq enhancement for multi-process application
Date
Msg-id 3A3F8B92.124E4E3F@free.fr
Whole thread Raw
In response to Re: libpq enhancement for multi-process application  (Daniele Orlandi <daniele@orlandi.com>)
List pgsql-hackers
> Uhm... I always thought that sharing the same socket between
> processes is wrong.

Well, I've never thought about it before this problem, but it definitely
appears to me like something not to do. Sharing remote object doesn't sound
right :-(

> My multi-process daemon works like apache with a pool of processes
> everyone with its own connection to the DB. The connection is only
> opened AFTER the fork and remains open as long as the process lives just
> to avoid a new connection for each accept.

When you can do it this way, that's nice'n'easy. In my case, I have to have a
connection before the fork, and keep it after in both parent and child,
eventhough it will be closed a few seconds later in the child. So, for now on,
the only-almost-clean-solution is to free the pgconn structure in the child
and reconnect when needed. This way, the parent process keeps its own
connexion. No other process is using it. Sounds safe, but kinda
"do-it-yourself" :-(

-- 
Sébastien Bonnet bonseb@free.fr                                 http://bonseb.free.fr/


pgsql-hackers by date:

Previous
From: Jeff Hoffmann
Date:
Subject: Re: Sample databases?
Next
From: Christopher Masto
Date:
Subject: Re: Who is a maintainer of GiST code ?