Re: forking problem with dbd::mysql




On May 9, 2007, at 5:41 PM, Jeff Pang wrote:



-----Original Message-----
From: Chas Owens <chas.owens@xxxxxxxxx>

The solution:

Setting a flag (InactiveDestroy) on the parent's handle inside the
child process prevents the automagic closing of the connection.

* the magic in this case is the DESTROY method of DBI::db

Using InactiveDestroy flag seems a standard way since this module's author provide this flag.
But it's maybe bring some problems when the applications are large enough,and it's not the fact that every programmer would disconnect their dbh connections in time.For example,consider the case programs were run under modperl and without Apache::DBI,using this flag would possibly make lots of db connections to database and consume db's socket source quickly.
Then for me I would maybe consider another way of creating its own dbh in child after fork.
Hope I'm right,:)


From perldoc:
This attribute is specifically designed for use in Unix applica-
tions that "fork" child processes. Either the parent or the child
process, but not both, should set "InactiveDestroy" on all their
shared handles. Note that some databases, including Oracle, don't
support passing a database connection across a fork.

In short -- you are lucky it can be supported.
But in order to keep things portable, this might be something to avoid?

.



Relevant Pages

  • Re: forking problem with dbd::mysql
    ... child process prevents the automagic closing of the connection. ... Using InactiveDestroy flag seems a standard way since this module's author provide this flag. ...
    (perl.beginners)
  • Re: forking problem with dbd::mysql
    ... Setting a flag (InactiveDestroy) on the parent's handle inside the ... child process prevents the automagic closing of the connection. ...
    (perl.beginners)
  • Re: exception handling around a signal handler
    ... Use a flag. ... check it in the 'main' loop communicating with the child process. ... I have not done any thread handling, but would the main thread not ... given by the second thread handling signals? ...
    (comp.unix.programmer)
  • Re: problem about CLOSE_WAIT
    ... what exactly that race condition is needs to be determined. ... One common problem is that multiple connections are sent to the same child process. ... the next child process cannot close the connection when it is done, ... connection is closed only when the last socket is closed. ...
    (comp.unix.programmer)
  • Re: VPN using RASDIAL default gateway problem
    ... it's very unlikely there is some kind of custom app running on my local box, ... If I open the connection and look at IPconfig, ... default gateway problem I see when using the rasdial api. ... look back at the phone book file, the IpPrioritizeRemote flag gets set to 1. ...
    (microsoft.public.win32.programmer.networks)