Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Why was it neccessary to pass a DBI handler by reference?

by Rhandom (Curate)
on Jan 28, 2004 at 19:55 UTC ( [id://324761]=note: print w/replies, xml ) Need Help??


in reply to Why was it neccessary to pass a DBI handler by reference?

Your references are fine - the Database is the problem. Using Oracle we had a similar issue. We kind of narrowed it down to the following:
Create a $dbh.
Fork.
Child disassociates from the parent.
Parent exits.
Child's $dbh hopefully stays alive.
Parent's $dbh goes out of scope.
Parent's $dbh sends close signal to database.
Database sends signal that the connection was closed.
Child's $dbh gets signal that the connection was closed.
Child's $dbh closes.
Alternate possibility goes something like the parent signals that he is done and database closes the door on the child. Child tries to use the connection but the door is already closed - so the child closes its own $dbh.

There is lot of magic in DBI. There is a lot going on in the specific driver for your database. I'd be very careful about forking and trying to make you're own persistent connections or sharing the $dbh around. In the end we found a way to disassociate the file descriptors so that the closing signals wouldn't be sent. Kind of a hack fix really.
my @a=qw(random brilliant braindead); print $a[rand(@a)];
  • Comment on Re: Why was it neccessary to pass a DBI handler by reference?

Replies are listed 'Best First'.
Re: Re: Why was it neccessary to pass a DBI handler by reference?
by kudra (Vicar) on Jan 29, 2004 at 14:09 UTC
    Interesting, but I'm not forking. By that I mean that I'm neither explicitly forking, nor am I creating the handle outside of the fastcgi run loop--the handle should be created anew for each connection. The handle is then shared between various pieces of code which need to make use of it, within the scope of a single program-run.
Re: Re: Why was it neccessary to pass a DBI handler by reference?
by Anonymous Monk on Jan 29, 2004 at 01:17 UTC
    The problem is not the database, it's that you're doing VERY BAD THINGS and expecting that it should work.

    You can't fork with an open database connection and expect it to work like that with any database, any operating system, any programming language. How would the database know you did that? How would the database driver know you did that?

Re: Re: Why was it neccessary to pass a DBI handler by reference?
by Rhandom (Curate) on Jan 28, 2004 at 19:57 UTC
    s/you're/your/ - Bad Grammer! Bad!
    my @a=qw(random brilliant braindead); print $a[rand(@a)];

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://324761]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-20 03:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found