[DB-SIG] Handling an open database connection after a fork?
Dieter.Maurer at Haufe.de
Dieter.Maurer at Haufe.de
Sun Jan 13 13:10:48 CET 2008
Mike Meyer wrote at 2008-1-11 11:35 -0500:
> ... existing connection in forked children ...
>So the question is - what should the child do to get a database
>connection? Can it just keep using the existing db & cu variables?
This is very unlikely.
I have had severe problems with different systems (ZODB connections,
LDAP connections). Not with Oracle connections, but probably only
because I do not use Oracle.
When the child is forked, it inherits the connections from the
parent -- but the protocols usually do not expect that several
processes (parent and child) are using them asynchronously.
In a single process, locks are often used to synchronize
access to a shared connection from different processes -- but
normal locks do not work across different processes -- and shared
memory semaphores are not that often used.
>If
>not, does it need to do anything special, or avoid doing anything, in
>order to not disrupt the parent processes use of those variables?
Open a new connection in your forked child.
It is not garanteed that this is sufficient.
For the ZODB, I have to take additional precautions.
I finally abondoned this approach completely (because, LDAP
was used deeply in my system and I had no control over the creation
of new connections) and am now using "fork+exec".
--
Viele Grüße
Dieter
Tel: 06881-7327 (Festnetz) oder 06881-5590036 (Internet)
More information about the DB-SIG
mailing list